frideosapps / frideos_flutter

An all-in-one Fllutter package for state management, reactive objects, animations, effects, timed widgets etc.

Home Page:https://pub.dev/packages/frideos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Black screen before opening the first screen

docbohanh opened this issue · comments

Hello,
I am trying to build the app with custom theme using ValueBuilder and AppStateProvider.

Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.14.6 18G103, locale en-VN)
• Flutter version 1.12.13+hotfix.5 at /Users/thanhla/flutter
• Framework revision 27321ebbad (6 weeks ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0

But my app appear black screen before opening the first screen.

    final theme = AppStateProvider.of<AppState>(context).currentTheme;

    return ValueBuilder<MyTheme>(
      streamed: theme,
      builder: (context, snapshot) => MaterialApp(
        title: 'Flutter Demo',
        theme: _buildThemeData(snapshot.data),
        onGenerateRoute: generateRoute,
        debugShowCheckedModeBanner: false,
        navigatorKey: navigatorKey,
        initialRoute: Routes.home,
      ),
    );

Please check my demo code, thank you!
quiz.zip

maybe I am missing initialData

    final theme = AppStateProvider.of<AppState>(context).currentTheme;

    return ValueBuilder<MyTheme>(
      streamed: theme,
      initialData: AppTheme.defaultLight, // add this line
      builder: (context, snapshot) => MaterialApp(
        title: 'Flutter Demo',
        theme: _buildThemeData(snapshot.data),
        onGenerateRoute: generateRoute,
        debugShowCheckedModeBanner: false,
        navigatorKey: navigatorKey,
        initialRoute: Routes.home,
      ),
    );