Help us understand the problem. What is going on with this article?

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

Idenon
記憶を無くした未来のオレへのメモを書く
cloudpack
Amazon Web Services (AWS) の導入設計、環境構築、運用・保守をサポートするマネジドホスティングサービス
https://cloudpack.jp/
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした