How to Manage Multiple User Flows (Two Apps) Within a Single Flutter Project?

Hi everyone,

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?

2 Likes

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.

2 Likes

Thank you! :slight_smile:
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.

1 Like

If you use get_it you could use different scopes to separate what can be accessed by which user types.

1 Like

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.

2 Likes

This is the way I would also do an then share the appropriate widgets, service, models and screens across the ‘user types’

Are you experiencing any specific issues?

Here’s what I did for an app that has 2 types of users

  1. Players
  2. 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.

1 Like