0

From inside the code for my app I'm connecting to different Algolia servers based on whether the app is running on a release or on a dev environment.

For mobile I could check PackageInfo.packageName and it works good. But for web that's not an option.

So, my question is - how can I make a function that, when running flutter web on release returns the String "release" and on dev returns the String "dev"?

Nikko
  • 163
  • 2
  • 11
  • Does this answer your question? [How can I check if a Flutter application is running in debug?](https://stackoverflow.com/questions/49707028/how-can-i-check-if-a-flutter-application-is-running-in-debug) – Ivo Oct 07 '22 at 10:50
  • No, because the release flavour is also being run in debug mode so we can use breakpoints to figure out where stuff is going wrong. However this gives me a good idea about setting environmental variables when running the app, and if kReleaseMode then use the release environment (because kReleaseMode would only be true for the app in the App Store) – Nikko Oct 07 '22 at 13:10
  • Ok, I also don't have an easy way of setting release or dev flavour from launch.json and instead can only run web dev if I change index.html, so setting environmental variables is also not working for me currently. – Nikko Oct 07 '22 at 13:23

0 Answers0