maybeOf static method

Returns reference of the AdaptiveThemeManager which allows access of the state object of AdaptiveTheme in a restrictive way. This returns null if the state instance of AdaptiveTheme is not found.

Implementation

static AdaptiveThemeManager<ThemeData>? maybeOf(BuildContext context) {
  context.dependOnInheritedWidgetOfExactType<
      InheritedAdaptiveTheme<ThemeData>>();
  final state = context.findAncestorStateOfType<State<AdaptiveTheme>>();
  if (state == null) return null;
  return state as AdaptiveThemeManager<ThemeData>;
}