2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Flutter で Android の productFlavors にて Target を指定する方法

Last updated at Posted at 2020-05-01

結論

指定の flavor のところにこれを書けばよい

project.target = "lib/main_development.dart"

flavor 指定の全体的にはこんな感じ

    flavorDimensions "default"

    productFlavors {
        development {
            project.target = "lib/main_development.dart"
            dimension "default"
            applicationIdSuffix ".dev"
            versionNameSuffix ".dev"
        }
        staging {
            dimension "default"
            applicationIdSuffix ".stg"
            versionNameSuffix ".stg"
        }
        production {
            dimension "default"
        }
    }

これで、flavor を development でビルドした時のターゲットが lib/main_development.dart になる

flutter run --debug --flavor development

あとがき

Flutter で Android の Build Variant 設定は比較的簡単で、設定方法についてはいろんな記事が出ているのですが、意外と Target の指定方法が見つかりづらかったので、記事にしました。

気づいたきっかけはこのコードです。
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/flutter.gradle#L583

Build Variant の設定方法自体は以下の記事が詳しくわかりやすいです。

flutterで本番/ステージング/開発を切り替える
https://qiita.com/ko2ic/items/53f97bb7c28632268b5a

Flutterで環境ごとにビルド設定を切り替える — iOS編
https://medium.com/flutter-jp/flavor-b952f2d05b5d

2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?