Flutter architecture template.
Project is structured in the following layers/modules:
-
Presentation
-
Domain
-
Data
-
Network
PRESENTATION LAYER is Flutter dependent. Defines its own custom hierarchy: screens ( widgets usually used as containers, similar to Android activities) and widgets (pieces of UI with behavior, similar to Android fragments).
DOMAIN LAYER provides state management through BLoC's for different use cases. Ex: performing a login
DATA LAYER is used to manage and orchestrate different data sources.
NETWORK LAYER performs net connections either directly or indirectly.
Data models are share across all modules, there is no custom data model per layer.
Events (in fact just simple Data Transport Object) are used to define use case inputs in domain layer and provide type safety.
flutter packages pub run build_runner build --delete-conflicting-ouputs
- Create a stateless screen
- Inherit from "BaseStatelessScreen"
- Override "buildScreenContents()" to return screen contents
- Optionally override getScreenTitle() to return title displayed on app bar (or "" if no app bar wanted) Ex: SplashScreen
- Create a stateful screen
- Inherit from "BaseStatefulScreen"
- Override "buildScreenContents()" to return widget contents
- Optionally override getScreenTitle() to return title displayed on app bar (or "" if no app bar wanted)
- Create a stateless widget
- Inherit from "BaseStatelessWidget"
- Override "buildWidgetContents()" to return widget contents Ex: LoadingWidget
- Create a stateful widget
- Inherit from "BaseStatefulWidget"
- Override "buildWidgetContents()" to return widget contents
- Create a stateful widget with bloc
- Inherit from "BaseStatefulWidgetWithBloc"
- Override buildWidgetContents() to return widget contents Ex: LoginButtonWidget
- Navigation
- Encapsulate navigation on AppNavigator.dart