Flutter Template
What to accomplish
- has tests
- basic auth flow
- riverpod as state provider
- logging (sentry)
- navigation (I used Beamer last time but might be something better out now)
- basic dashboard screen display user information
- basic settings screen to modify user profile.
- built in responsiveness
- built in flavors (dev,staging,prod)
Top TODOs
- setup login flow
- make api call using dio and cache response using dio cacher
- Use auto route for navigtion
- setup guards for users that are not auth'ed
- run web integration tests in github actions
DONE
- full test suite running in github actions
- logging with sentry monitoring
- riverpod
- Flavors configured
- built in responsiveness
- full CI lint/unit/integration
- Pre-Push githook to force lint before pushing
π
Getting Started First step
Run dart pub global activate derry
This will allow you to run commands defined in derry.yaml like derry lint
Support for running integration tests with flavors is added https://github.com/flutter/flutter/pull/89045 If you are on master you can run derry test_all
or derry e2e_iphone
To run unit tests derry unit_test
This project contains 3 flavors:
- development
- staging
- production
To run the desired flavor either use the launch configuration in VSCode/Android Studio or use the following commands:
# Development
$ flutter run --flavor development --target lib/main_development.dart
# Staging
$ flutter run --flavor staging --target lib/main_staging.dart
# Production
$ flutter run --flavor production --target lib/main_production.dart
*Flutter Template works on iOS, Android, and Web.
Running in Docker
Start local emulator
- install android studio and set up a emulator
ln -s ~/Library/Android/sdk/tools/emulator /usr/local/bin/emulator
emulator -list-avds
should list out your installed devices- export the paths
export ANDROID_SDK=$HOME/LibraryAndroid/sdk
export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:$PATH
- run
emulator -avd $(emulator -list-avds)
to open the emulator. adb tcpip 5555
After doing all the setup above you only need to run this command from here on out.
Setup
- Download Visual Studio
- Install Docker Plugin
- Install Remote Development Plugin
- Optional Download Docker Desktop
Once you have installed all of these, open Visual Studio and open this project. Visual Studio will auto detect the Dockerfile and build it for you as well as copy the project files in the docker container using settings from the devcontainer.json file. If you have a andriod emulator open and have typed adb tcpip 5555
into your terminal the device should show up in the docker container type adb devices
to make sure if not follow the steps below
For Web
In Docker
- Run
sh flutter-web.sh
For Android:
- Open up an android emulator / or plugin your device
- type
adb devices
and make sure the device shows - in your terminal type
adb tcpip 5555
In the docker continer:
- Run
adb connect host.docker.internal:5555
- clilck allow permission on the andriod
sh flutter-android-emulator.sh
Errors: If you get The message received from the daemon indicates that the daemon has disappeared.
When trying to launch on android increase your docker memory to 4 gigs. Do this by going to the docker app -> preferences -> resourses
π§ͺ
Running Tests To run all unit and widget tests use the following command:
$ derry test_all
$ derry e2e
$ derry unit
To view the generated coverage report you can use lcov.
# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/
# Open Coverage Report
$ open coverage/index.html