brightnessOf static method

Brightness brightnessOf(
  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 can be found in the given context, or its brightness is null, it will fall back to MediaQueryData.platformBrightness.

See also:

Implementation

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