I am building a Bus Management System using a feature-based approach. The project has two types of users, and the login API returns the user type. My question is: Can I use Flutter flavors to manage and switch between the two user flows?
No because Flavors are two app versions, so you can’t run the app and then switch.
You have to do that with navigation and routing logic inside your app.
If you want to build two separate apps from the sane source, then flavors could be a way to go, although I would probably do it differently and move all comob code into one package and create two separate app projects in that case.
Thank you!
In my Flutter project, I have multiple user types. Based on the login API response (which includes the user type), I navigate each user to the appropriate screen where they can access and interact with their specific features. Some features and logic may be shared across different user types. For now, I believe this is the best solution.
You can structure your Flutter project with separate directories for each app’s user flow, using independent main.dart entry points and routing configurations. Then, share common widgets, services, and models across both flows to avoid code duplication.
Here’s what I did for an app that has 2 types of users
Players
Trainers
Based on their roles inside the object I was getting from backend (BE) I was handling some UI components (hide them or show them etc.)
As per functionality, if a UI was getting too complex, I simply have it separately e.g.player_calendar.dart and trainer_calendar.dart for rest, I had some local widgets and based on user roles’ check I was showing them
e.g.
home_screen.dart
Has 2 widgets _player_section.dart and _trainer_section.dart and somewhere in code
if (user.isPlayer) _PlayerSection() else _TrainerSection()
I hope this helps.
BUT: My honest learning from this was to have 2 separate apps man, with shared widgets/theme that you can keep in some package. Life will get a lot easier.
Using contents of this forum for the purposes of training proprietary AI models is forbidden. Only if your AI model is free & open source, go ahead and scrape. Flutter and the related logo are trademarks of Google LLC. We are not endorsed by or affiliated with Google LLC.