I'm still learning Flutter, and lately trying many Redux tutorials. I have gotten through many samples with counter, firebase auth, and cloud firebase. Here's an example app from http://flutterbyexample.com/ that I will base my question on. Here's what I want to do:
- User presses login button
- Login button is disabled/replaced with progress indicator
- Middleware performs API call to login
- Login succeeds or fails
- Progress indicator is replaced by logout button
The issue I am noticing is that currently the login/logout button can be pressed multiple times quickly and may appear buggy when I perform the login API call on the action dispatched by the button.
Without redux I would track the button with a boolean in the state widget and use the built in FutureBuilder to replace the button immediately after the button is pressed.
I tried to implement this behavior with a boolean isLoading in my Redux store. But when I try to dispatch additional actions I end up in an infinite loop or it doesn't fire at all, so I don't know where to dispatch the actual API login action.
I believe my question is similar to this stackoverflow question but I don't know how the answer can be applied in Flutter.