brightnessOf static method
Retrieves the Brightness to use for descendant Arna widgets, based on the value of ArnaThemeData.brightness
in the given context
.
If no ArnaTheme can be found in the given context
, or its brightness
is null, it will fall back to
MediaQueryData.platformBrightness.
Throws an exception if no valid ArnaTheme or MediaQuery widgets exist in the ancestry tree.
See also:
- maybeBrightnessOf, which returns null if no valid ArnaTheme or MediaQuery exists, instead of throwing.
- ArnaThemeData.brightness, the property takes precedence over MediaQueryData.platformBrightness for descendant Arna widgets.
Implementation
static Brightness brightnessOf(BuildContext context) {
final _InheritedArnaTheme? inheritedTheme =
context.dependOnInheritedWidgetOfExactType<_InheritedArnaTheme>();
return inheritedTheme?.theme.data.brightness ??
MediaQuery.of(context).platformBrightness;
}