brightnessOf static method

Brightness brightnessOf(
  1. BuildContext context
)

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

If no MacosTheme 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 MacosTheme or MediaQuery widgets exist in the ancestry tree.

See also:

Implementation

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