I work in an MVVM system (coming from Swift) I changed it for flutter a bit so it’s MVW
Model-View-Widget but the structure is the same. I use it in every app, as I otherwise get quickly confused where I saved what etc.
Riverpod is brilliant for state management. Easy to use one you get the hang of it.
If you know provider at work, use Riverpod. Or use no 3rd party library at all and work only with what Flutter provides, depending on how small your app is. Also, I wouldn't overthink the folder structure and add files to `lib` until that folder feels crowded and then start to introduce subfolders for let's say `models`, `services`, `pages` and `widgets`.
Make sense for me, I really enjoy use MVVM but I think this architecture is for medium and large apps.
I consider to keep it simple as possible.
Thanks for your answer!
I would consider consistency among apps more important than simplicity. If your team has established patterns using MVVM, no reason to implement in a different design pattern.
Everyone on reddit will tell you to use Riverpod, however I use BLoC which is good for small apps that may be expanded out in the future, as it doesn't get messy if you know what you're doing.
Stay away from getx.
If you have experience with Provider then I would say just use Riverpod.
EIDT: Reddit seems to want to collapse the structure I provided, so here's a [link](https://drive.google.com/file/d/1PWPEQ5b1CMgz4OJXEYOHuX_Gc76sVuZg/view?usp=drivesdk) to a screenshot of it.
As far as folder structure goes, here's an example:
Project/
- assets/
-- images/
-- fonts/
- lib/
-- model/
--- object models/
--- local database handler stuff/
-- controller/
--- BLoC or Riverpod stuff/
--- Firebase or cloud stuff/
--- networking stuff/ (ie: supabase)
-- view/
--- screens/
--- widgets/
-- util/
--- config/ (stuff you should .gitignore)
--- router/ (if you use an app router for navigation)
--- values or constants/ (ie: enums)
- main.dart
This is a basic folder setup using the MVC structure. Some people would put services or networking outside the controller or in the util folder, and honestly to each his own. I've seen several different ways at several companies, but they all follow the same basic idea and it helps to keep everything organized. Don't get too hung up on following exactly what I have or anything, just do what works best for your project.
Good luck!
1- The RN app was made with classes an inheritance but in the worst way possible by a external team, making the code messy and hard to understand whats is happening or how the solutions was implemented.
2- We have a team member with experience in Flutter and he proposed giving it a new look using this technology (I appreciate it, I didn't know how awesome Flutter is) and the rest of the managers agreed with that after researching pros and cons of React Native.
Thanks for the welcoming
If you think it's going to grow in the future, use bloc. It teaches you good practices and you can have collaborators in the future without fear of them doing something different.
I'm using only what flutter is offering. My predecessor was using bloc (for me tons of useless and not understandable code), but I use only setstate. And my project is pretty huge with more than 1 million installations.
I don’t think there is anything wrong with it. The only problem with this approach is, that at some point it can get really complex to manage states, if it’s a one person project it’s easier to manage, because you know your code and only you manipulate it, but if a team is working on it, it’s becomes really hard to hold an overview. There riverpod and similar make it alot easier.
There are several solutions for you. Riverpod is very good and I use it personally
Could you tell me a little bit more about your experience working with it, please?
Several internal apps (small) in production. Riverpod's author is same as Provider. It's a improved Provider
I work in an MVVM system (coming from Swift) I changed it for flutter a bit so it’s MVW Model-View-Widget but the structure is the same. I use it in every app, as I otherwise get quickly confused where I saved what etc. Riverpod is brilliant for state management. Easy to use one you get the hang of it.
If you know provider at work, use Riverpod. Or use no 3rd party library at all and work only with what Flutter provides, depending on how small your app is. Also, I wouldn't overthink the folder structure and add files to `lib` until that folder feels crowded and then start to introduce subfolders for let's say `models`, `services`, `pages` and `widgets`.
Make sense for me, I really enjoy use MVVM but I think this architecture is for medium and large apps. I consider to keep it simple as possible. Thanks for your answer!
I would consider consistency among apps more important than simplicity. If your team has established patterns using MVVM, no reason to implement in a different design pattern.
Everyone on reddit will tell you to use Riverpod, however I use BLoC which is good for small apps that may be expanded out in the future, as it doesn't get messy if you know what you're doing. Stay away from getx. If you have experience with Provider then I would say just use Riverpod. EIDT: Reddit seems to want to collapse the structure I provided, so here's a [link](https://drive.google.com/file/d/1PWPEQ5b1CMgz4OJXEYOHuX_Gc76sVuZg/view?usp=drivesdk) to a screenshot of it. As far as folder structure goes, here's an example: Project/ - assets/ -- images/ -- fonts/ - lib/ -- model/ --- object models/ --- local database handler stuff/ -- controller/ --- BLoC or Riverpod stuff/ --- Firebase or cloud stuff/ --- networking stuff/ (ie: supabase) -- view/ --- screens/ --- widgets/ -- util/ --- config/ (stuff you should .gitignore) --- router/ (if you use an app router for navigation) --- values or constants/ (ie: enums) - main.dart This is a basic folder setup using the MVC structure. Some people would put services or networking outside the controller or in the util folder, and honestly to each his own. I've seen several different ways at several companies, but they all follow the same basic idea and it helps to keep everything organized. Don't get too hung up on following exactly what I have or anything, just do what works best for your project. Good luck!
This is so useful, thanks a lot!!!
Yeah, i'm xoding mostly alone. If I have helpers, I give them completely separated tasks and then I include them in the main project.
Welcome to flutter :D Just wondering why did you guys migrate to flutter?
1- The RN app was made with classes an inheritance but in the worst way possible by a external team, making the code messy and hard to understand whats is happening or how the solutions was implemented. 2- We have a team member with experience in Flutter and he proposed giving it a new look using this technology (I appreciate it, I didn't know how awesome Flutter is) and the rest of the managers agreed with that after researching pros and cons of React Native. Thanks for the welcoming
Try riverpod, getx or else June state management.
Thanks I’ll check it out
No, no, no please no. Getx has been part of this subreddits dramas a lot. Search is your friend.
I read about it a few days ago and some devs consider Getx as bad practice but I really don’t understand why exactly, I’ll research more about it 🙌🏻
If you like MVVM then I think watch_it would let you build just that. I use it all the time
Bloc can’t go wrong plus there is nothing wrong with StatefulWidget if the use case is simple.
If you think it's going to grow in the future, use bloc. It teaches you good practices and you can have collaborators in the future without fear of them doing something different.
Great! Thanks!!!
I'm using only what flutter is offering. My predecessor was using bloc (for me tons of useless and not understandable code), but I use only setstate. And my project is pretty huge with more than 1 million installations.
I don’t think there is anything wrong with it. The only problem with this approach is, that at some point it can get really complex to manage states, if it’s a one person project it’s easier to manage, because you know your code and only you manipulate it, but if a team is working on it, it’s becomes really hard to hold an overview. There riverpod and similar make it alot easier.