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

StoreProviderError exception thrown: No StoreProvider<AppState> found #119

Closed
nikeshjobanputra opened this issue Mar 24, 2019 · 1 comment

Comments

@nikeshjobanputra
Copy link

Currently working on a small app using Flutter and Redux but having an issue when introducing navigation with flutter_redux.


class AddItemPageState extends State<AddItemPage> {
  var controller = new TextEditingController();

  @override
  Widget build(BuildContext context) {
    return new StoreConnector<AppState, AddItemPageModel>(
        converter: (store) => AddItemPageModel.create(store),
        builder: (BuildContext context, AddItemPageModel addItemPageViewModel) {
          return new Scaffold(
              body: new ListView(
            children: <Widget>[
              new TextField(
                controller: this.controller,
                decoration:
                    new InputDecoration(labelText: "Enter new to do item"),
                onSubmitted: (String s) {
                  print(s);
                  controller.text = "";
                  addItemPageViewModel.onAddItem(s);
                  Navigator.pop(context);
                },
              )
            ],
          ));
        });
  }
}

When it tries to build this widget this exception is being thrown:

I/flutter (27229): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (27229): The following StoreProviderError was thrown building StoreConnector<AppState,
I/flutter (27229): AddItemPageModel>(dirty):
I/flutter (27356): Error: No StoreProvider found.

I'm new to Flutter and Redux but after reading a couple other Git issues on this I can't seem to find the fix. My understanding is you should call StoreProvider<AppState> at the root of your application, then use StoreConnector to access the store and map it to a view model. I've done exactly that but still I'm receiving this exception.

The code is available here on the feature/usingSharedPreferences branch https://github.com/nikeshjobanputra/flutter-todo-app/tree/feature/usingSharedPreferences

I must be doing something stupid but I can't see where! Thanks in advance

@brianegan
Copy link
Owner

Hey there -- sorry about the delay! I just checked out that code / branch and ran the app, but didn't run into the problem. Did you find the fix!?

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