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

Question regarding storing flutter UI state in cross-platform store #110

Closed
jimmyff opened this issue Mar 1, 2019 · 3 comments
Closed

Comments

@jimmyff
Copy link

jimmyff commented Mar 1, 2019

Hi, I have some flutter specific UI variables that I need to store (some are flutter specific data types). Should this king of thing be stored in my redux store? My store will be shared between a Flutter & Angular app which is why there would be issue if I have flutter specific data-types in there.

At the moment I'm using a stateful widget that stores the flutter specific UI stuff however finding it clunky using stateful widgets & redux. What is your recommendation for this situation?

Thanks

@brianegan
Copy link
Owner

If you need to keep these values in the Store and reuse them for both Flutter and Angular, it's best to create some way to store that data that isn't tied to angular or flutter.

Why? Say you're using the VoidCallback typedef from Flutter. In order to use that, you'll need to import Flutter. However, you can't import Flutter in Angular projects.

Therefore, you can store that VoidCallback as a void Function() instead. That is a generic definition that requires no Flutter import, and will therefore be usable by both Flutter and Angular.

Overall, I'd definitely encourage you to split "View Logic" from "Redux Logic." E.g. navigating, showing popups, handing text input, etc are all different between angular and Flutter, and so those parts should be confined to your Flutter or angular app. The shared parts, such as fetching data and parsing JSON, can be reused!

It might seem silly to store some stuff in the Redux and other "View Related" data stuff in a StatefulWidget, but overall it will make your store more reusable between platforms and make those Widgets easy to move around since they're self-contained.

Does that help?

@jimmyff
Copy link
Author

jimmyff commented Mar 6, 2019

Hey Brian thanks for the response.

Yeah that does make total sense. I just wasn't sure if mixing stateful widgets with redux was a bad idea, glad to hear it's okay.

I was going down the path of using conditional imports for the platform specific parts of the state but just storing the UI stuff separately simplifies things.

Thanks

@brianegan
Copy link
Owner

Sure thing!

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