INNER CODE UNIT · Dart
maybeOf
BirjuVachhani/adaptive_theme · packages/adaptive_theme/lib/src/adaptive_theme.dart:89
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>;
}
/// Returns reference of the [AdaptiveThemeManager] which allows access of
/// the state object of [AdaptiveTheme] in a restrictive way.
///
/// This does NOT establish a dependency on the [InheritedWidget], and will
/// not cause the widget to rebuild when the theme changes.
///
/// This is safe to call inside initState or other places where you
/// cannot call [BuildContext.dependOnInheritedWidgetOfExactType].