Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: No StoreProvider<dynamic> found. #89

Closed
gaozp opened this issue Oct 12, 2018 · 2 comments
Closed

Error: No StoreProvider<dynamic> found. #89

gaozp opened this issue Oct 12, 2018 · 2 comments

Comments

@gaozp
Copy link

gaozp commented Oct 12, 2018

Hi
I'm also facing this problem , I have tried #54 solution that move app_state.dart to root directory , but it didn't make sense.

Here is my error trace:

I/flutter (27168): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (27168): The following StoreProviderError was thrown building Builder:
I/flutter (27168): Error: No StoreProvider<dynamic> found. To fix, please try:
I/flutter (27168):           
I/flutter (27168):   * Using Dart 2 (required) by using the --preview-dart-2 flag
I/flutter (27168):   * Wrapping your MaterialApp with the StoreProvider<State>, 
I/flutter (27168):   rather than an individual Route
I/flutter (27168):   * Providing full type information to your Store<State>, 
I/flutter (27168):   StoreProvider<State> and StoreConnector<State, ViewModel>
I/flutter (27168):   * Ensure you are using consistent and complete imports. 
I/flutter (27168):   E.g. always use `import 'package:my_app/app_state.dart';
I/flutter (27168):   
I/flutter (27168): If none of these solutions work, please file a bug at:
I/flutter (27168): https://github.com/brianegan/flutter_redux/issues/new
I/flutter (27168): 
I/flutter (27168): When the exception was thrown, this was the stack:

Here is my code

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {

  final Store<MainState> store = new Store<MainState>(
    appReducer,
    initialState: new MainState(
      user: User.empty(),
    )
  );

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new StoreProvider<MainState>(
      store: store,
      child:  new MaterialApp(
            localizationsDelegates: [
              // ... app-specific localization delegate[s] here
              GlobalMaterialLocalizations.delegate,
              GlobalWidgetsLocalizations.delegate,
              LocalizationDelegate.delegate,
            ],
            supportedLocales: [
              const Locale('en', 'US'), // English
              const Locale('zh', 'CH'), // Chinese
              // ... other locales the app supports
            ],

            routes:{
              RoutesName.routesHomePage: (context)=> new HomePage(),
              RoutesName.routesWelcomePage: (context)=> new WelcomePage(),
    
            },

//      theme: defaultTheme,
            theme: ThemeData.dark().copyWith(primaryTextTheme: new TextTheme(
              title: new TextStyle(
                  fontFamily: 'Ubuntu'
              ),
            )),
//            home: new HomePage(this.userprovider)

        )
    );
  }
}

Looking forward for your reply .thx.

@gaozp
Copy link
Author

gaozp commented Oct 12, 2018

:)
Sorry I find the problem where it is
Store store = StoreProvider.of<MainState>(context);

So I'll close this issue.

@gaozp gaozp closed this as completed Oct 12, 2018
@wukuy
Copy link

wukuy commented Jan 14, 2019

:)
抱歉,我发现问题所在
Store store = StoreProvider.of<MainState>(context);

所以我将结束这个问题。

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants