'is it possible to create the same screen for both user and admin but for admin with extra functions like CRUD in flutter?

I'm having hard time creating logic for this. I jave a flutter app in which i want to show same screen for both admin and user but for admin i want to add CRUD facilities. How can i achieve this in flutter?



Solution 1:[1]

I am assuming that you have some sort of a backend/database where you know what kind of user is logging in. If you can share that information with Flutter, you can use conditional rendering of widgets.

You can use the Ternary operator.

user.type == 'admin' ? CustomWidget() : null

You can refer to this stackoverflow post that shares a few other ways to conditionally render.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rohit Rao