https://github.com/alexisl61/fluttertemplate
My personal template when starting a new flutter project
https://github.com/alexisl61/fluttertemplate
flutter template viewmodel
Last synced: 2 months ago
JSON representation
My personal template when starting a new flutter project
- Host: GitHub
- URL: https://github.com/alexisl61/fluttertemplate
- Owner: AlexisL61
- Created: 2024-08-16T15:51:37.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-01-14T18:45:07.000Z (6 months ago)
- Last Synced: 2025-01-31T15:09:02.777Z (5 months ago)
- Topics: flutter, template, viewmodel
- Language: C++
- Homepage:
- Size: 278 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# flutter_template
My personal template when starting a new flutter project. It includes a dependency injection system (get_it), a folder architecture and a model-viewmodel-view implementation for flutter.
## Quick start
- Launch with provider Dummy : `flutter run -t ./lib/main_dummy.dart`
- Launch with provider Live : `flutter run -t ./lib/main_live.dart`## Providers
This template use two providers to split the repositories in case you are not in the same environment. There are two providers that are not implemented :
- Live : Which take a baseUrl to communicate with an api
- Dummy : Which use static string to simulate the communication to the apiTo split this behavior, each provider instantiate their own repositories in their provider file (dummy will instantiate the DummyExampleRepository and live will instantiate the LiveExampleRepository).
## Folders
### Components
Components are used to store small widget that can be reused by any page or dialog of the app.
They can be either :
- An atom : A small widget
- A molecule : A widget containing atoms
- An organism : A widget containing moleculesIf a component behavior become too big, there should be a ViewModel with it
### Model
The model contains every data class and the core concept of the Model-View-ViewModel.
### Pages
Pages contains every pages of the app. It's a screen the user will see containing components and specific widget
Every pages should at least have a ViewModel.
### Providers
The providers help you splitting your code behavior depending of the environment.
### Services
Every services give you a way to retrieve data and create data class with it. They can only be called from Repositories.
### Repositories
Every repositories helps you calling services and transformers to retrieve data as you want.
### Transformers
Transformers let you transform data, from one class to an another. They can only be called from Repositories.
### Utils
Utils contain every extensions for the project. It can be extensions for base class (e.g. string, int, boolean) and for specific classes too.
## Diagram
```mermaid
flowchart LR
Page
ViewModel
Component
Repository
Transformer
Service
DataClass[Data class]
Page<-->ViewModel
Page<-->Component
ViewModel-->Repository
Repository-->Transformer
Repository-->Service
Component .->ViewModel
Service-- Create -->DataClass
Transformer-- Transform -->DataClass
```