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

Can't Find Store Producer and Reducer #49

Closed
tensor-programming opened this issue May 13, 2018 · 3 comments
Closed

Can't Find Store Producer and Reducer #49

tensor-programming opened this issue May 13, 2018 · 3 comments

Comments

@tensor-programming
Copy link

I read issue #46 and that does seem related to my issue however how there is a bit more in my case.

I took a stateless widget and wrapped the Store Provider in it and attached the Reducer to this widget as a static function. When I tried to wrap the root widget in this stateless widget it gave me the "can't find store provider" error like in #46. If I transplant the Store Provider from the stateless widget and directly put it into my root widget, I am unable to gain access to my reducer (I took the reducer out of the wrapper stateless widget and just made it a normal top level function). I happened to leave the wrapper widget code mostly alone (aside from removing the reducer from it) but its not attached to anything and it finds the reducer when it is passed into the Store Provider there.

On the other hand when I pass the same reducer into the Store Provider in the root widget it gives me this very bizarre error: the argument type '(AppState, dynamic) → AppState can't be assigned to the parameter type '(AppState, dynamic) → AppState

Any Ideas of what exactly is going on here? This is a really confusing error and even taking the reducer and its logic and putting it directly into my main file does not solve this problem.

@brianegan
Copy link
Owner

brianegan commented May 14, 2018

Hey hey... Sorry about the trouble & delay, traveling at the moment. Dang, this is definitely the number 1 problem folks have experienced, and it almost always comes down to a problem with how Dart resolves imports. Could you please try importing all of your files in a consistent way? E.g. always with Relative or always with package-style imports (import 'my_reducer.dart' or import 'package:my_lib/my_reducer.dart')? Another problem: Sometimes if you define the AppState in the main.dart file and import main.dart in another file, it will think the AppState is different in the two files.

If you try those solutions and they don't work, would you be able to provide a bit more code, such as a repo that I could take a look at?

@tensor-programming
Copy link
Author

tensor-programming commented May 17, 2018

@brianegan Actually, I now know what the problem is exactly. Normally when working with flutter (or dart in general), I import all packages using the package import method; I never use relative path because i find it is messy. However, sometimes I am rushing and I don't realize that I accidently did import something via relative path. I found this out the hard way in a different situation dart-lang/sdk#33149.

It seems you were right about the import paths etc. I will be closing this issue. Thanks for taking the time to get in touch with me.

@brianegan
Copy link
Owner

brianegan commented May 17, 2018

Glad it's resolved! I kinda think we should provide more feedback to the Dart team about this issue. I see it come up quite often.

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