This project is a starting point for scalable and complex flutter applications.
This project uses fvm to manage flutter versions. If you have already installed flutter or dart on your machine, you should uninstall it before installing fvm. After installation run the following command to install the correct flutter version:
# To install the correct flutter version defined in .fvm/fvm_config.json
fvm use
# The template ususally uses the stable version of flutter. FVM doesn't care if your stable version is up to date. To make sure you have the latest stable version run the following command:
fvm flutter upgrade
To make working with fvm
easier we recommend creating aliases for the flutter
and dart
commands in your .bashrc
or .zshrc
file:
alias flutter="fvm flutter"
alias dart="fvm dart"
This will ensure that running any flutter
or dart
command always uses the project's defined flutter version or the accompanying dart version.
Additionally since the project uses an architecture made up of multiple packages, we use melos to manage the packages. To install the correct version of melos and initialize the project run the following command:
flutter pub get
We also recommend you setup an alias for working with melos:
alias melos="flutter pub run melos"
In the melos.yaml
File in the project root directory you can find all the scripts that are available to you. To run a script simply run the following command:
melos run <script_name>
The most important commands are:
melos bs
ormelos boostrap
- Run the bootstrap command (Install all dependencies in all packages)melos run codegen
- Runbuild_runner
in all relevant packages
The app has three environments: development
, staging
and production
. But only
development
is initially configured.
Using VSCode all environments are configured as launch configurations. If you need to run the app from the command line you can use the following command:
flutter run --flavor <environment> --target app/lib/main_<environment>.dart
# Example
flutter run --flavor development --target app/lib/main_development.dart
Note: The mocked sign in credentials are
password
.
Generally the project consists of the following packages.
This is the entry point for launching the app and contains the ui pages and routing.
The core package contains the EnvironmentConfig, logging and utility functions used in all packages, etc. It also acts as a dependency core, providing essential packages with centrally defined versions.
The database package contains the database and the corresponding local dtos, tables and daos.
The api client package contains a generated api client, which processes the basic network requests and generates the corresponding remote dtos.
The api package references the generated api client and acts as a proxy which injects e.g. the auth token and provides wrapper functions for network requests for each feature.
Each feature has its own package, which is divided into the following sections:
- application: The application folder contains the logic for the ui, e.g. controller and usecases, as well as forms
- domain: The domain folder contains models, repositories, provider and widgets
- infrastructure: The infrastructure folder contains the repository implementation and mapper functions
The Project uses functional programming patterns from fpdart.
This repository also contains a simple backend service to store the todos. Get it running by following the instructions in the backend README.
You will need to configure your IP address in the packages/core/lib/src/environment.dart
file. To get the app connected to your local backend instance.
This repository also contains simple tasks to get familiar with the structure. These are available in english and german.