Nullable CupertinoThemeData.brightness



CupertinoThemeData.brightness is now nullable.



CupertinoThemeData.brightness is now used to override MediaQuery.platformBrightness for Cupertino widgets. Before this change, the CupertinoThemeData.brightness getter returned Brightness.light when it was set to null.

Description of change


Previously CupertinoThemeData.brightness was implemented as a getter:

Brightness get brightness => _brightness ?? Brightness.light;
final Brightness _brightness;

It is now a stored property:

final Brightness brightness;

Migration guide


Generally CupertinoThemeData.brightness is rarely useful outside of the Flutter framework. To retrieve the brightness for Cupertino widgets, now use CupertinoTheme.brightnessOf instead.

With this change, it is now possible to override CupertinoThemeData.brightness in a CupertinoThemeData subclass to change the brightness override. For example:

class AlwaysDarkCupertinoThemeData extends CupertinoThemeData {
  Brightness brightness => Brightness.dark;

When a CupertinoTheme uses the above CupertinoThemeData, dark mode is enabled for all its Cupertino descendants that are affected by this CupertinoTheme.



Landed in version: 1.16.3
In stable release: 1.17



Design doc:

API documentation:

Relevant issue:

Relevant PR: