0

Google Play has different deployment environments for Android apps, like Production, Open Test track, Closed Test track, and Internal Test.

Similarly, Apple App Store Connect allows us to deploy either in production or to TestFlight and other testing environments.

Is it possible to know if a flutter app is running in Production or in one of these test environments? My use case is that I would like to enable some debugging and troubleshooting features in my app only when it is not deployed in Production, if possible.

Please bear in mind I am not looking for Dart isDebug variable, since apps published on the test environments are also built on release mode, so this is not the solution I need.

Ulysses Alves
  • 2,297
  • 3
  • 24
  • 34
  • Do you mean the non-production app is built in release mode and you want to enable the debug mode for that? – CbL Aug 03 '22 at 02:42
  • No @CbL. When I upload the compiled app to the stores it is already in release mode. Then I can publish this compilation to test channels or to production. I would like a way to check if the App is running in production or in a test channel like TestFlight on Apple AppStore Connect or yet on a Closed Test Track on Google Play, for exemple. – Ulysses Alves Aug 05 '22 at 04:44
  • I think Android is hardly to do that if your are using Google Play Beta Scheme becuase when you push beta app to public version, it in fact increses app version number automatically which is hard to be predicted. Unless all test apk are from other channel and public one is Google Play, then you may check the installation source in app setting info is from 3rd party or Google Play. IOS should still be possible, i have done this half year ago, you can try this https://stackoverflow.com/questions/55759596/how-to-know-installed-application-is-installed-via-testflight-or-appstore – CbL Aug 05 '22 at 09:18
  • @CbL Google Play does not increase the app version number after I publish it from beta to production. Both the app version name and build number stay the same. – Ulysses Alves Aug 22 '22 at 18:32
  • i see. they have changed the rules. – CbL Aug 24 '22 at 04:29

1 Answers1

1

They are just channels to publish the application to users, not actual deployment environments.

Debug features need to be added in the build phase. One simple way is to pass values to build and alter the functionality according to them.

flutter build --dart-define=MY_VAR=MY_VALUE

Use in code

String.fromEnvironment('MY_VAR')

See Using --dart-define in Flutter.

Use flavors when different applications (has own application/bundle id) are needed for different channels.

See Creating flavors for Flutter.

user18309290
  • 5,777
  • 2
  • 4
  • 22