Comments (10)
In some way I solved the problem.
Basically I created another project, and copy-pasting the code the same error was thrown, but when I tried to rewrite it (without referring at the previous version) everything worked. Then I figured out that it depended on the imports, as @brianegan told me some comments above, so using only relatives imports everything was okay, so I tried to replace every absolute import on the previous project with a relative one, but it didn't work, probably due to some other messy stuff. Now I'm working on the second project.
from flutter_redux.
Ok, voodoo magic. I'm at IO and will see if I can chat with a Dart team member about this issue :) A lot of peeps suffer from it!
from flutter_redux.
Sorry about that! I need to add one more error case to the error message: How are you importing your files? If you're using relative paths, e.g. import '../store.dart'
rather than import package:my_app/store.dart
you may run into this issue.
If that's not the case, could you please provide a bit more code, even a repo with the code that's failing? That way I can help debug :)
from flutter_redux.
Thanks @brianegan for your answer, but trying to import with absolute path didn't change anything, the error message is still there.
Unfortunately I can't provide the repo, but basically my code looks like:
import 'package:test/modules/store.dart';
runApp(
new StoreProvider<AppState>(
store: store,
child: new MaterialApp(
title: 'Test App',
theme: new ThemeData(
textTheme: new TextTheme(
display1: new TextStyle(fontFamily: 'Rubik'),
)
),
home: new TestApp()
)
)
);
my store:
var store = new Store<AppState>(
rootReducer,
initialState: new AppState(
user: new UserState(null, true),
connection: new ConnectionState(false)
),
middleware: middlewares
);
and in my TestApp basically there's a StoreConnector that causes the error, nothing happens if I avoid to use that.
return new StoreConnector<AppState, UserState>(
converter: (store) => store.state.user,
builder: (BuildContext ctx, userState) {
if (userState.currentUser == null) {
return new Landing(userState.loading);
}
return new Dashboard();
},
);
The error:
I/flutter (11060): The following NoSuchMethodError was thrown building StoreConnector<AppState, UserState>(dirty):
I/flutter (11060): The getter 'store' was called on null.
I/flutter (11060): Receiver: null
I/flutter (11060): Tried calling: store
from flutter_redux.
Hrm, interesting -- could you please check your pubspec.lock
and verify you're on flutter_redux
version 0.5.0? Since 0.4.1, if the store is null, it should throw a different error message from this.
Thanks!
from flutter_redux.
Thanks again for your help, looks like I'm on the correct version:
flutter_redux:
dependency: "direct main"
description:
name: flutter_redux
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
from flutter_redux.
Hrm, this is odd... I can't quite reproduce the issue, and it's a bit baffling that you're getting that particular error message, since the code explicitly does a null-check before accessing the store :(
Does the example app in this repo run for you without issue? Another option: Could you please try accessing the store directly via StoreProvider.of<AppState>(context)
in the build method to see if that's failing?
from flutter_redux.
The example in this repo works correctly.
Trying to call StoreProvider.of(context)
in the build method an error is thrown but with StoreProvider.of<AppState>(context)
everything works.
from flutter_redux.
Now the error is different. My code:
return new StoreConnector<AppState, UserState>(
converter: (store) => store.state.user,
builder: (BuildContext ctx, userState) {
...
}
);
It throws this error:
The following StoreProviderError was thrown building StoreConnector<AppState, UserState>(dirty):
Error: No StoreProvider<AppState> found. To fix, please try:
* Using Dart 2 (required) by using the --preview-dart-2 flag
* Wrapping your MaterialApp with the StoreProvider<State>, rather than an individual Route
* Providing full type information to your Store<State>, StoreProvider<State> and
StoreConnector<State, ViewModel>
Which is quite weird because my StoreProvider is implemented like:
final store = new Store<AppState>(...);
...
return new StoreProvider<AppState>(
store: store,
child: new MaterialApp(...)
);
from flutter_redux.
Hey @darioielardi -- Ok, making progress! That's definitely the error you should be seeing. However, this is an odd one since it seems as though you're following the directions.
The last thing I could think of: Does your AppState
live in it's own file, or does it live in the main.dart
where you declare the StoreProvider<AppState>
? If it lives side-by-side with your StoreProvider<AppState>
, this can cause odd errors with Dart.
Please see this issue for more details and an open-source example that's been fixed: #35
from flutter_redux.
Related Issues (20)
- [Question]: Mixing global and local state
- How to not accept change notifications when the Router is not at the top level, and then take the initiative to obtain the changes when the Router returns to the top level HOT 1
- onDidChange called twice HOT 8
- Is this package still actively maintained?
- `onWillChange` and `onDidChange` errors are swallowed HOT 4
- Warning related to `?` operator on Linux/Dev channel. HOT 2
- Import Store data type
- Widgets binding error after upgrading flutter version to 2.13.0-0.1.pre HOT 1
- onDidChange not working as expected HOT 3
- Build warning with Flutter 3.0 HOT 5
- flutter_redux depends on flutter_redux, version solving failed HOT 3
- onWillChange and onDidChange called twice after state update HOT 2
- Passing Store as an argument to MethodChannel and Background Isolate
- Question on how to use the reducer right way HOT 2
- [Question]: Any thoughts on difference between ignoreChange and distinct?
- Socket and Flutter_redux HOT 18
- Dispatching an action that does not alter state rerenders the widget, causing an infinite loop HOT 5
- How to watch redux store change inside useEffect? HOT 5
- [Question] is it expected that the store doesn't run until frames render? HOT 1
- After push a new page, and Dispatching an action, there is an infinite loop
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_redux.