Skip to content

sestegra/flutter-flavor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flutter-flavor

Manage your Flutter app flavors.

Getting started

In order to create a new Flutter project with 'dev' and 'prod' flavors, launch these commands.

$ flutter create <output directory> [arguments]
$ cd <output directory>
$ flutter-flavor enable dev prod

Then, use --flavor option with Flutter command.

$ flutter build apk --flavor dev
$ flutter build apk --flavor prod
$ flutter build ios --flavor dev
$ flutter build ios --flavor prod

Optional tools

Launcher icons per platform / per flavor

See pending Pull Request on following project fluttercommunity/flutter_launcher_icons#69

Assets management per platform / per flavor

In order to support different set of assets depending on platform and flavor parameters, see procedure in following project https://github.com/sestegra/flutter_assets_flavors.

Usage

Manage your Flutter app flavors.

Usage: flutter-flavor <command> [arguments]

Available commands:
  check              Check if flavors have been enabled
  enable [flavors]   Enable flavors and optionaly add flavor(s)
  list               List enabled flavors
  add <flavors>      Add flavors
  remove <flavors>   Remove flavors
  help               Display help information```

check

  • Check if flavors have been enabled, exit status is different of 0 if not
$ flutter-flavor check

enable

  • Enable flavors only
$ flutter-flavor enable
  • Enable flavors and add 'foo' flavor
$ flutter-flavor enable foo

list

  • List enabled flavor
$ flutter-flavor list

add

  • Add 'foo' flavor
$ flutter-flavor add foo
  • Add 'foo' and 'bar' flavors
$ flutter-flavor add foo bar

remove

  • Remove 'foo' flavor
$ flutter-flavor remove foo
  • Remove 'foo' and 'bar' flavors
$ flutter-flavor remove foo bar

Limitations

  • This project is only a POC (Proof-Of-Concept) to ease flavor management with Flutter app
  • Only a Bash script with patch/grep/sed/awk commands
    • Possible improvement could be an implementation in Dart to support all platforms
      • Open question: How to read/write build.gradle file in Dart ? (petitparser ?)
      • Open question: How to read/write project.pbxproj file in Dart ? (petitparser ?)
  • Only tested on macOS
    • Potential issues with sed/awk commands on Linux
  • flavors tags are removed from XCode project file when updating it via XCode
    • Possible workaround could be to gate their removal with git-hooks using flutter-flavor check command

References

Documentation

Projects

Articles

About

Manage your Flutter app flavors.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages