maybeBrightnessOf static method

Brightness? maybeBrightnessOf(
  1. BuildContext context
)

Retrieves the Brightness to use for descendant Material widgets, based on the value of ThemeData.brightness in the given context.

If no InheritedTheme or MediaQuery can be found in the given context, it will return null.

See also:

Implementation

static Brightness? maybeBrightnessOf(BuildContext context) {
  final _InheritedTheme? inheritedTheme =
      context.dependOnInheritedWidgetOfExactType<_InheritedTheme>();
  return inheritedTheme?.theme.data.brightness ?? MediaQuery.maybePlatformBrightnessOf(context);
}