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

StoreProvider not found #35

Closed
lockerfish opened this issue Apr 10, 2018 · 7 comments
Closed

StoreProvider not found #35

lockerfish opened this issue Apr 10, 2018 · 7 comments

Comments

@lockerfish
Copy link

lockerfish commented Apr 10, 2018

I am getting StoreProvider not found when I try connecting from another class. Hoping the code below helps understanding the issue.

 return new StoreProvider<AppState>(
      store: store,
      child: new MaterialApp(
        title: title,
        theme: new ThemeData(
          primaryColor: Colors.lightBlue,
        ),
        home: new HomePage(), /// <<--- USING STORE_CONNECTOR AS BELOW FAILS WITHIN HOMEPAGE
        // home: new StoreConnector<AppState, int>(
        //   converter: (storexx) => storexx.state.luckyNumber,
        //   builder: (context, count) {
        //     return new Text(count.toString());
        //   },
        // ),
      ),
    );
@brianegan
Copy link
Owner

Hey there @lockerfish, sorry about that! Could you please tell me which version of Flutter / Redux / flutter_redux you're using?

I can't see anything obviously wrong with the code in the code you've pasted in. Does the example from this repository work for ya?

@lockerfish
Copy link
Author

lockerfish commented Apr 11, 2018

@brianegan Not problem. I see the benefits of using flutter redux so THANKS!.. I basically took the example from the repo and decompose it, move widgets out to separate files, global stuff, app stuff, etc.. Here is a link to the test project... https://github.com/lockerfish/flutter_redux_test. Check out app.dart file. It breaks when trying to use a new IncrementButton widget... Hope this helps

@brianegan
Copy link
Owner

Thanks for the full project, I'll take a look :)

@brianegan
Copy link
Owner

brianegan commented Apr 11, 2018

Ah, ok -- you're running into one of the most annyoing things about Dart! For some reason, you need to be very careful when importing files in your own project.

Rather than directly referencing the file, global.dart, you want to specify the full "path":

import 'package:flutter_redux_test/global.dart';

Otherwise, for some reason, Dart will think that import 'global.dart' and import 'package:flutter_redux_test/global.dart'; are different :/

Diff to get it working:

diff --git a/lib/app.dart b/lib/app.dart
index 8205a18..efedfb9 100644
--- a/lib/app.dart
+++ b/lib/app.dart
@@ -2,8 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter_redux/flutter_redux.dart';
 import 'package:flutter_redux_test/increment_button.dart';
 import 'package:redux/redux.dart';
-import 'cool_widget.dart';
-import 'global.dart';
+import 'package:flutter_redux_test/cool_widget.dart';
 
 class FlutterReduxApp extends StatelessWidget {
   final Store<int> store;
diff --git a/lib/main.dart b/lib/main.dart
index b89686f..ab338dd 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,7 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:redux/redux.dart';
-import 'global.dart';
-import 'app.dart';
+import 'package:flutter_redux_test/global.dart';
+import 'package:flutter_redux_test/app.dart';
 
 void main() {
   final store = new Store<int>(counterReducer, initialState: 0);

@lockerfish
Copy link
Author

That's it! The good news is VS Code is defaulting to using package.

@passsy
Copy link

passsy commented Jul 13, 2018

Just ran into this and wasted a full evening...

@brianegan
Copy link
Owner

@passsy Did ya get it fixed following these instructions? If so, might be good to chime in on the linked issue for the Dart lang Repo. More reports will hopefully bump up the priority.

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

3 participants