A Null-Safety flutter project acting as a learning/code reference zone
Based on
- Riverpod (v1/v2)
- Page Transitions
- Math Expressions
- Flex Color Scheme
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
NB: To view Google Ads, switch to the
googleadsbranch as it does not work with thewebversion.
flutter pub run flutter_launcher_icons:mainUsing the flutter_native_splash package
flutter pub run flutter_native_splash:createThe base sturcture is based on Code With Andrea's app structure. It offers a sweet spot between feature-first and Layer first approach, which -honestly- makes a lot more sense.
However, after building several prototypes (small quick apps), the structure feels augmented towards a Bloc-like architecture, where it begins to feel like there are too many files & folders for even the simplest of tasks.
The latest architecture features a somewhat better and more flexible architecture, offering a sweet spot between feature-first, layer-first, and Code with Andreas's architectures.
NB: Check the real folder structure contained in this project for a better visual understanding.
Changes include:
- Renamed
presentation->ui: No need to name thepresentationlayerpresentation. It's too lengthy and what we hate as devs is writing too much! - Renamed
controllers->providers. We're dealing with providers after all, aren't we? - Renamed
services->repositories. However, if you prefer naming yours services, well and good. The key point here is be CONSISTENT in your project. We will use repositories as it's the most popular convention. - StateNotifier states(classes) moved from
providersfiles to individualmodelsfolder. enumsmoved todata. For a Clean architecture, it would be better keeping all enums on their own and not in providers. It becomes easier to maintain the project in the long run.- Merged
application,domain,controllers/providers->data. Any state has been separated from theui. Any piece of state/logic has been moved out of thepresentation/uifolder. - Any form
TextEditingControllerbe used inside aStatefulHookConsumerWidgetviauseTextEditingController. Riverpod Hooks combined with Flutter Hooks are a fantastic way for handling such use-cases. Same goes for animations, pageControllers, e.t.c. found in the flutter hooks package. Form Validation can be done via thevalidatorspackage, or for more complex validation, the providers can handle that (StateNotifiers) - Or however you deem fit 🤷♂️ - Inside the
ui, any Screen must be suffixed withScreene.g.OrdersScreen. Any other widget should be viewed as apartial/widget/fragmentto the main screen, and, therefore, can be re-used multiple times in the entire project - not just by the feature. Screens, on the other hand, cannot be re-used in other widgets. - Flexibility:
- If a
featureonly requires a screen and a provider, the folder structure can then be:- ui
- providers
- If a
featurerequires a screen, a provider, and a state/model/stateNotifier class, the folder structure can then be:- ui
- data
- providers
- models
- If a
featurerequires a screen, a provider, a state/model/stateNotifier class, and enums, the folder structure can then be:- ui
- data
- providers
- models
- enums
- If a
featurerequires a screen, a provider, a state/model/stateNotifier class, enum, and repository, the folder structure can then be:- ui
- data
- providers
- models
- enums
- repositories
- exceptions
- If a
For apps that have an admin and user dashboard, this architecture gets in line with the following architecture:
- main.dart
- src
- app_routes.dart
- common_widgets
- utils
- features
- onboarding
- splash
- home
- auth
- admin
- dashboard
- orders
- invoices
- reports
- user
- dashboard
- orders
- cart
- invoices
and each fature can then follow the guidelines above. The ui and data can now be tested individually.
NB: Check the real folder structure contained in this project for a better visual understanding.


