This is a Flutter application that demonstrates a scalable and maintainable approach to handling different themes for multiple user types. The project leverages the Riverpod state management library and employs the Factory and Strategy design patterns to create a clean, organized codebase.
-
Multi-User Theming: The app's theme dynamically changes based on the logged-in user's type (
basic,premium, oradmin). -
State Management with Riverpod: User state is managed globally using a
StateProvider, allowing the UI to reactively update when the user changes. -
Factory Pattern: A
UserFactoryclass centralizes the logic for creating and configuring aUserobject, ensuring that each user type is correctly initialized with its specific features. -
Strategy Pattern: The
Featureabstract class and its concrete implementations (BasicFeature,AdvancedFeature,AdminFeature) define different behaviors (e.g.,canEdit()), which are then applied to each user type. This makes the code highly extensible without largeif/elsestatements. -
Modular Code: Themes for each user type are defined as separate
ThemeDataobjects, keeping the styling logic distinct and easy to modify.
To run this project, make sure you have the Flutter SDK installed.
-
Clone this repository or copy the code into a new Flutter project.
-
Install the required packages by running
flutter pub getin your terminal. -
Run the app:
flutter run
