fysoul17 / google_maps_place_picker

Place picker on Google Maps for Flutter
MIT License
222 stars 357 forks source link

Do not use Mutable Providers. #89

Closed vinceramcesoliveros closed 3 years ago

vinceramcesoliveros commented 3 years ago

If possible. create the map provider first, then the search provider. Using a mutable provider variable causes inconsistent and messy dependency flow.

You could add a linter in your repository to know what to follow best practices. When I fork this repo and added a linter. a lot of red lines & dynamic types in the code which is a red flag to me. Thanks!

B1TB0Y01 commented 3 years ago

I didn't get any red lines and I used the pedantic package.

vinceramcesoliveros commented 3 years ago

I actually had to put implicit dynamic set to error because for me, that is an anti-pattern to have dynamic values(providers) in a single variable. as my Title says, do not use mutable providers as they are hard to maintain state if other contributors want to help the author of this package.

I really discourage programmers to just slip their JS knowledge to dart just because the syntax are familiar.

B1TB0Y01 commented 3 years ago

So you would create multiple variables for the provider?

vinceramcesoliveros commented 3 years ago

I would say that Inject 2 different providers. But that doesn't mean I have to create multiple mutable variables. So the very first provider to be injected would be the Maps Provider, followed by the Search Provider. The discussion here is just to help maintain the repo if it remains inactive. as the community practices immutable variables and not do 2 things at once.

My case solved a lot of issues in the issue section and the fix was to inject 2 different providers and not have mutable providers. I have my own lint config and follow dart's best practices to fix the problem, but I am not sure if the author approves it or not just because we have different set of practices on how to solve a problem.

B1TB0Y01 commented 3 years ago

I got your point now. Thank you.

vinceramcesoliveros commented 3 years ago

Update: I'll be closing this one, because I saw the code seems to have providers become injectable, but still it is mutable and might be different from what I've solved.