How can i have multiple login in my Flutter/Dart App

78 Views Asked by At

How can i have this functionality to have multiple accounts in the app and user can switch, add, remove them (Example:Instagram)

1

There are 1 best solutions below

0
DelonPrinsloo On

Assuming your app is trying to manage user accounts locally:

There are several ways to approach this issue. What we did for our app locally:

  • Have a local database (like objectbox or something)
  • We created the appropriate entities/models which would contain all the information regarding a specific user (like name, password, security token, etc.)
  • We put and retrieved the aforementioned entities from the database using a repository that we wrote.
  • We had views where a user could select accounts, register accounts, etc.
  • These views were managed by controllers that are persistent through dependency injection.
  • The controllers handled all the business logic, calling specific use cases in order to retrieve data, etc.
  • Our app can auth users locally, but registering requires server authentication and a security token is then passed to that user and persisted for that user.
  • Our app uses CLEAN architectural design patterns for different features and services throughout our app. Maybe research what architectural design patterns would best fit your needs.