Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix red screen on app launch from theme lookup in initState

Barnabas130b6c89dcbe
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dart
index d53ed5c5..1de211bd 100644
--- a/lib/screens/app_shell.dart
+++ b/lib/screens/app_shell.dart
@@ -244,7 +244,11 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Ticker
_wasCasting = _cast.isCasting;
_cast.addListener(_onCastChanged);
// Try immediately; _onLibraryChanged picks it up once data loads.
- _deriveCoverScheme();
+ // Deferred to post-frame so Theme.of(context) inside _deriveCoverScheme
+ // doesn't establish an inherited-widget dependency during initState.
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) _deriveCoverScheme();
+ });
context.read<LibraryProvider>().addListener(_onLibraryChanged);
WelcomeSheet.showIfNeeded(context);
_checkForUpdate();