maybeOf static method

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

Implementation

static AdaptiveThemeManager<CupertinoThemeData>? maybeOf(
    BuildContext context) {
  context.dependOnInheritedWidgetOfExactType<
      InheritedAdaptiveTheme<CupertinoThemeData>>();
  final state =
      context.findAncestorStateOfType<State<CupertinoAdaptiveTheme>>();
  if (state == null || state is! AdaptiveThemeManager<CupertinoThemeData>) {
    return null;
  }
  return state as AdaptiveThemeManager<CupertinoThemeData>;
}