flutter_flavorizr 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

Flutter Flavorizr #

A flutter utility to easily create flavors in your flutter application

Pub Dart CI Star on GitHub License: MIT

Getting Started #

Let's start by setting up our environment in order to run Flutter Flavorizr

Prerequisites #

Side note: this tool works better on a new and clean Flutter project. Since some processors reference some existing files and a specific base structure, it could be possible that running Flutter Flavorizr over an existing project could throw errors.

Before running Flutter Flavorizr, you must install the following software:

These prerequisites are needed to manipulate the iOS project and schemes. If you are interested in flavorizing Android only, you can skip this step. Keep in mind that you will have to use a custom instructions set with Android and Flutter processors only, otherwise an error will occur.

Installation #

This package is intended to support development of Dart projects. In general, put it under dev_dependencies, in your pubspec.yaml:

  flutter_flavorizr: ^1.0.3

You can install packages from the command line:

pub get

Create your flavors #

Once all of the prerequisites have been installed and you have added flutter_flavorizr as a dev dependency, you have to edit your pubspec.yaml and define the flavors.

Example #

Add a new key named flavorizr and define two sub-items: app and flavors. Under the flavors array you can define the name of the flavors, in our example apple and banana. For each flavor you have to specify the app name, the applicationId and the bundleId.

      flavorDimensions: "flavor-type"

        name: "Apple App"

        applicationId: "com.example.apple"

        bundleId: "com.example.apple"

        name: "Banana App"

        applicationId: "com.example.banana"
        bundleId: "com.example.banana"

Available fields #


appObjecttrueAn object describing the general capabilities of an app
flavorsArraytrueAn array of items. Each of them describes a flavor configuration
instructionsArrayfalseAn array of instructions to customize the flavorizr process
assetsUrlStringhttps://github.com/AngeloAvv/flutter_flavorizr/releases/download/v1.0.3/assets.zipfalseA string containing the URL of the zip assets file. The default points to the current release
ideStringfalseThe IDE in which the app is being developed. Currently only vscode or idea
Available instructions
assets:downloadMiscellaneousDownloads the assets zip from the network
assets:extractMiscellaneousExtracts the downloaded zip in the project .tmp directory
assets:cleanMiscellaneousRemoves the assets from the project directory
android:buildGradleAndroidAdds the flavors to the Android build.gradle file
android:androidManifestAndroidChanges the reference of the app name in the AndroidManifest.xml
android:dummyAssetsAndroidGenerates some default icons for your custom flavors
flutter:flavorsFlutterCreates the flutter flavor configuration file
flutter:appFlutterCreates the app.dart entry
flutter:pagesFlutterCreates a set of default pages for the app
flutter:targetsFlutterCreates a set of targets for each flavor instance
ios:xcconfigiOSCreates a set of xcconfig files for each flavor and build configuration
ios:buildTargetsiOSCreates a set of build targets for each flavor and build configuration
ios:schemaiOSCreates a set of schemas for each flavor
ios:dummyAssetsiOSGenerates some default icons for your custom flavors
ios:plistiOSUpdates the info.plist file
ios:launchScreeniOSCreates a set of launchscreens for each flavor
ide:configIDEGenerates debugging configurations for each flavor of your IDE

android (under app)

flavorDimensionsString"flavor-type"falseThe value of the flavorDimensions in the android build.gradle file

app (under flavorname)

nameStringtrueThe name of the App

android (under flavorname)

applicationIdStringtrueThe applicationId of the Android App
generateDummyAssetsbooltruefalseTrue if you want to generate dummy assets (icon set, strings, etc)

ios (under flavorname)

bundleIdStringtrueThe bundleId of the iOS App
generateDummyAssetsbooltruefalseTrue if you want to generate dummy assets (xcassets, etc)

Usage #

When you finished defining the flavorizr configuration, you can proceed by running the script with:

flutter pub run flutter_flavorizr

Run your flavors #

Once the process has generated the flavors, you can run them by typing

flutter run --flavor <flavorName> -t lib/main-<flavorName>.dart


flutter run --flavor apple -t lib/main-apple.dart
flutter run --flavor banana -t lib/main-banana.dart

Customize your app #

Flutter_flavorizr creates different dart files in the lib folder. In the flavors.dart file we have the F class which contains all of our customizations.

class F {
  static Flavor appFlavor;

  static String get title {
    switch (appFlavor) {
      case Flavor.APPLE:
        return 'Apple App';
      case Flavor.BANANA:
        return 'Banana App';
        return 'title';


The process creates a simple title customization: a switch which checks the current appFlavor (defined in our app starting point) and returns the correct value. Here you can write whatever you want, you can create your custom app color palette, differentiate the URL action of a button, and so on.

If you are wondering how to use these getters, you can find an example under the pages folder: in the my_home_page.dart file, the page shown after the launch of the app, we can see a clear reference on the title getter defined in the F class.

Further developments #

  • Let the user define its custom set of available instructions.
  • Create Firebase processors.
  • Use a groovy parser to better manipulate the build.gradle file

Please feel free to submit new issues if you encounter some problems with it.

License #

Flutter Flavorizr is available under the MIT license. See the LICENSE file for more info.

1.0.3 #

  • Added IDE processors (vscode and idea)
  • Updated README

1.0.2 #

  • Fixed zip asset extraction using sync
  • Fixed zip asset creation with recursive param

1.0.1 #

  • First release!


import 'package:flutter/material.dart';

void main() {

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      home: MyHomePage(title: 'Flutter Demo Home Page'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.

  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          // Invoke "debug painting" (press "p" in the console, choose the
          // "Toggle Debug Paint" action from the Flutter Inspector in Android
          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
          // to see the wireframe for each widget.
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
              'You have pushed the button this many times:',
              style: Theme.of(context).textTheme.headline4,
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_flavorizr: ^1.0.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_flavorizr/flutter_flavorizr.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart


  • flutter_flavorizr that is a package requiring null.

Package not compatible with runtime flutter-web on web


  • package:flutter_flavorizr/flutter_flavorizr.dart that imports:
  • package:flutter_flavorizr/processors/processor.dart that imports:
  • package:flutter_flavorizr/processors/ios/xcconfig/ios_xcconfig_targets_file_processor.dart that imports:
  • package:flutter_flavorizr/processors/ios/xcconfig/ios_xcconfig_file_processor.dart that imports:
  • package:flutter_flavorizr/processors/ios/xcconfig/ios_xcconfig_mode_file_processor.dart that imports:
  • package:flutter_flavorizr/processors/commons/shell_processor.dart that imports:
  • dart:io

Health suggestions

Fix lib/processors/ide/vscode/vscode_launch_processor.dart. (-1 points)

Analysis of lib/processors/ide/vscode/vscode_launch_processor.dart reported 2 hints:

line 43 col 26: Avoid using braces in interpolation when not needed.

line 43 col 40: Avoid using braces in interpolation when not needed.

Fix lib/parser/parser.dart. (-0.50 points)

Analysis of lib/parser/parser.dart reported 1 hint:

line 31 col 8: Don't import implementation files from another package.

Fix lib/processors/commons/new_folder_processor.dart. (-0.50 points)

Analysis of lib/processors/commons/new_folder_processor.dart reported 1 hint:

line 21 col 52: Avoid using braces in interpolation when not needed.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (xml).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
archive ^2.0.11 2.0.13
checked_yaml ^1.0.0 1.0.2
flutter 0.0.0
io ^0.3.4 0.3.4
json_annotation ^3.0.1 3.0.1
xml ^3.6.1 3.7.0 4.2.0
yaml ^2.2.0 2.2.1
Transitive dependencies
args 1.6.0
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
meta 1.1.8 1.2.2
path 1.7.0
petitparser 3.0.4
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
build_runner ^1.0.0
json_serializable ^3.0.0