Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
2
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

Organization

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

結論

指定の 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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
2
Help us understand the problem. What are the problem?