Nullable CupertinoThemeData.brightness
Summary
#CupertinoThemeData.brightness
is now nullable.
Context
#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
.
Timeline
#Landed in version: 1.16.3
In stable release: 1.17
References
#Design doc:
API documentation:
Relevant issue:
Relevant PR:
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2024-04-04。 查看文档源码 或者 为本页面内容提出建议。