INNER CODE UNIT · Dart
read
BirjuVachhani/adaptive_theme · packages/adaptive_theme/lib/src/adaptive_theme.dart:107
static AdaptiveThemeManager<ThemeData>? read(BuildContext context) {
final state = context.findAncestorStateOfType<State<AdaptiveTheme>>();
if (state == null) return null;
return state as AdaptiveThemeManager<ThemeData>;
}
/// returns most recent theme mode. This can be used to eagerly get previous
/// theme mode inside main method before calling [runApp].
static Future<AdaptiveThemeMode?> getThemeMode() async {
return (await ThemePreferences.fromPrefs())?.mode;
}
}
class _AdaptiveThemeState extends State<AdaptiveTheme>
with WidgetsBindingObserver, AdaptiveThemeManager<ThemeData> {
late bool _debugShowFloatingThemeButton = widget.debugShowFloatingThemeButton;
@override