1

I am setting up an Android app that points to a particular Firebase environment based on the build type:

  • Debug build -> dev Firebase environment
  • Release build -> prod Firebase environment

I followed this guideline and ended up having some productFlavors in my gradle file and stored google-services.json for both environment in android/app/src/{env}.

buildTypes {
    release {
        signingConfig signingConfigs.release
    }

    debug {
        debuggable true
    }
}

flavorDimensions "env"
productFlavors {
    dev {
        dimension "env"
    }

    prod {
        dimension "env"
    }
}

The issue is, now I need to specify --flavor when running flutter build apk.

Is there a way to automatically determine the flavor from the build type, e.g., running flutter run will point to dev, and running flutter run --release will point to prod?

Michael Yuwono
  • 2,452
  • 1
  • 14
  • 32

1 Answers1

0

You have to use the --flavor. The official documentation lists other blog articles which goes into details on setting up your IDE etc.

If you are using a terminal to flutter run maybe a hacky approach would be an alias for flutter run --flavor app1 etc.

Sandeep Chayapathi
  • 1,490
  • 2
  • 13
  • 31