maybeBrightnessOf static method

Brightness? maybeBrightnessOf(
  1. BuildContext context

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

If no CupertinoTheme can be found in the given context, it will fall back to MediaQueryData.platformBrightness.

Returns null if no valid CupertinoTheme or MediaQuery widgets exist in the ancestry tree.

See also:


static Brightness? maybeBrightnessOf(BuildContext context) {
  final _InheritedCupertinoTheme? inheritedTheme = context.dependOnInheritedWidgetOfExactType<_InheritedCupertinoTheme>();
  return inheritedTheme? ?? MediaQuery.maybePlatformBrightnessOf(context);