-
Notifications
You must be signed in to change notification settings - Fork 215
Access store outside of Widget AND use Navigation outside of Widget (In Thunk Action for example) #184
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
Comments
Okay, I tried many different things now and changed my whole App structure to have my store inside the main method and access it in other files via Callbacks but I still get the same error. My Code now looks like this: `void main() { errorCallback() { runApp(EasyLocalization( class MyApp extends StatelessWidget { MyApp( @OverRide |
Okay, ... after 7 hours I found the error, I was using StoreConnector without providing the types in a file that I didn't know I was already using the StoreConnector in. The solution for Tried calling: pushReplacementNamed<Object, Object>("/home", arguments: null) was to NOT dispatch actions before the navigatorKey is passed to the material app. Since I was using a firebase auth listener I was always dispatching before the navigatorKey was passed to the Material App. My solution was to create a separate AuthHandler and pass this as a child to the MaterialApp. |
Hello,
I'm not sure if this is the right place to ask.
I couldn't make it to work to use the store.dispatch outside and use navigatorKey.currentState.push.... outside of a Widget.
To use the store outside of the Widgets, I create the store inside a separate file and pass it to the Store Provider, which wraps my main App.
--> Works
I also try to use a navigatorKey inside a navigationMiddleware. The navigatorKey is created in the same file as the store and is then passed as an argument to the navigationMiddleware.
Though, I'm getting this error
Tried calling: pushReplacementNamed<Object, Object>("/home", arguments: null)
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 NavigationMiddleware.call (package:flutter_redux_navigation/src/navigation_middleware.dart:33:24)
#2 Store._createDispatchers.
package:redux/src/store.dart:255
#3 LoggingMiddleware.call
package:redux_logging/redux_logging.dart:120
#4 Store._createDispatchers.
package:redux/src/store.dart:255
#5 thunkMiddleware
package:redux_thunk/redux_thunk.dart:49
#6 Store._createDispatchers.
package:redux/src/store.dart:255
#7 Store.dispatch
package:redux/src/store.dart:267
#8 navigateAfterLogin.
package:socialcort_user_flutter/…/auth/helper.dart:61
#9 thunkMiddleware (p<…>
It seems like this is happening because the store is created outside of the main() function, not sure about that though.
Do you have any suggestions on how to use the store outside of widgets as well as using the navigation outside of widgets? For Example in middleware or in actions/helpers.
That would be really kind.
If you have any questions about the question, just hit me up. Thank you for the effort already!
The text was updated successfully, but these errors were encountered: