Skip to content

dscdut/flutter_base

Repository files navigation

flutter_base

A new Flutter project.

Getting Started

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.

Setup environment before running

if you have any environment variable, you should add it to config.json

Run build_runner

Run:

$ fvm flutter pub run build_runner build --delete-conflicting-outputs

Generate localizations

View document for details

Run:

$ fvm flutter pub run easy_localization:generate -S assets/locales
$ fvm flutter pub run easy_localization:generate -S assets/locales -f keys -o locale_keys.g.dart

Generate app flavor

View document for details

Run:

$ fvm flutter pub run flutter_flavorizr

If you encounter the issue about "tmp script sh" when generate firebase service. You must run:

$ fvm flutter pub run flutter_flavorizr -p assets:download,assets:extract,google:firebase,assets:clean

Generate Assets dart code from assets folder

With Flutter Gen

Install Flutter Gen

$ dart pub global activate flutter_gen

Or add it as a part of build_runner

dev_dependencies:
  build_runner:
  flutter_gen_runner:

Run Flutter Gen With command line

$ fluttergen -c pubspec.yaml

With build_runner

$ fvm flutter pub run build_runner build

Generate template code with mason_cli

View document for details

Install mason_cli

Active from https://pub.dev

$ dart pub global activate mason_cli

Or install from https://brew.sh

$ brew tap felangel/mason
$ brew install mason

Initializing

Get all bricks registered in mason.yaml run:

$ mason get

Then you can use 'mason make' to generate bricks. Suppose you want to generate a module with bloc, you should run

$ mason make bloc_module -o lib/modules

Flutter build

Build Android release

  • fvm flutter build apk --release --flavor <envname> -t lib/main<env_name>.dart

Example: Build STAGING

fvm flutter build apk --release --flavor staging -t lib/main_staging.dart

Bundle Android Release

fvm flutter build appbundle --flavor staging -t lib/main_stating.dart