CupertinoThemeData.brightness 现可为空
概要
Summary
CupertinoThemeData.brightness
现可为空。
CupertinoThemeData.brightness
is now nullable.
背景
Context
CupertinoThemeData.brightness
现被用于覆盖 Cupertino widgets 的 MediaQuery.platformBrightness
。在此之前,
CupertinoThemeData.brightness
为空时返回 Brightness.light
。
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
此前 CupertinoThemeData.brightness
由 getter 实现:
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
一般来说 CupertinoThemeData.brightness
很少会在 Flutter 框架层外用到。现在如果要检索 Cupertino widgets 的亮度,使用 CupertinoTheme.brightnessOf
代替它即可。
Generally CupertinoThemeData.brightness
is rarely useful outside of the Flutter framework.
To retrieve the brightness for Cupertino widgets,
now use CupertinoTheme.brightnessOf
instead.
在此更改后,现在可以在 CupertinoThemeData
子类中覆盖 CupertinoThemeData.brightness
值来改变亮度。例如:
With this change, it is now possible to override
CupertinoThemeData.brightness
in a CupertinoThemeData
subclass to change the brightness override. For example:
class AwaysDarkCupertinoThemeData extends CupertinoThemeData {
Brightness brightness => Brightness.dark;
}
当有一个 CupertinoTheme
使用上述 CupertinoThemeData
时,所有受此 CupertinoTheme
影响的 Cupertino 类组件都将启用深色模式。
When a CupertinoTheme
uses the above CupertinoThemeData
,
dark mode is enabled for all its Cupertino descendants
that are affected by this CupertinoTheme
.
时间表
Timeline
实现版本:1.16.3
稳定版本:1.17
Landed in version: 1.16.3
In stable release: 1.17
参考资料
References
设计文档:
Design doc:
API 文档:
API documentation:
相关 issue:
Relevant issue:
相关 PR:
Relevant PR: