samedi 13 mars 2021

Different screens for different roles or conditional rendering of widget based on roles in one screen? (Flutter)

I developing my first "complex" application in flutter+firebase where there are 4 different roles in the application. Guest user, Plus user, Pro user and Admin user. Different user groups have access to different functions in the application (different widget shown etc).

I see two possible alternatives how this can be implemented.

1: Different screens/views for different user groups. Home_Guest, Home_Plus, Home_Pro and Home_Admin and load screen depending on user roll (There are over 10 different screens/view in the aplication so it will be different 40+ screens/view If I go this route).

2: One screens/views where different widgets are loaded depending on the user group. Home: if Guest load A, if Plus load A+B, if Pro load A+B+C and if Admin load A+B+C+D etc...

Pros/Cons:

1: More code and some repetition of code

2: Less code, no repetition of code but more complex logic

I know that there are probably different opinions from different developers but i have tried to find an article, book etc on the subject but find nothing. What I'm asking is if there is one (or more) "best practice" patterns that I can follow? And any book, article, etc. that describes this pattern?

Aucun commentaire:

Enregistrer un commentaire