-
Notifications
You must be signed in to change notification settings - Fork 215
Perform action automatically on a flutter page based on appState changes. #45
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
Hey hey :) Thanks for writing in! One option that might work well for this case is to pass an Please feel free to try that, and if it doesn't quite work please write back and we can think of more options :) |
Thanks! @brianegan I tried the onWillChanged function and it works, I just have a problem with checking the exact change on the Store. So the body of the function won't run on every state change. Trying to check for the change in the |
Cool, glad that worked for ya. To solve the second challenge, one solution is to use the |
Hi @brianegan Noticed that you closed the issue. I'm sorry for the late responses but, I don't understand how setting the distinct property to true will help me in this case. Here's my storeConnector:
Where am I supposed to perform the check if the |
It looks like your view model is missing the required equality functions to be able to utilize the distinct property. From the flutter_redux.dart file: |
I had somewhat the same problem. I decided to make a "ErrorSnackbar" widget which listens for changes on the state.error variable, displays them in a snackbar and then clears up the variable. I ended up with this code: https://gist.github.com/ScholliYT/d26dc1b947ff48eb0c96bc7c6d4e086e I think it's bad practice to just return an empty Text widget but I could not figure out how to do it better and this seems to work. Just add the Widget to your Scaffold like this:
|
Uh oh!
There was an error while loading. Please reload this page.
I'm trying to implement this idea where I dispatch a log-in action and from the log-in middleware, launch another action that changes a variable in the appState if there's an error in the log in process. That's done.
The issue is, I tried to use the storeConnector, since it updates the application based on appState changes, to check for the change and open a SnackBar when the variable changes as shown in the code for the container below, but I'm obviously not doing this the right way:
I'm sorry if this is such a tyro question but I'm just getting started with Redux and I still dont know how everything works out yet. The commented part is the part I tried to implement the "listen" for the appState change.
The text was updated successfully, but these errors were encountered: