3

I am using the dart-define parameter for switching b/w URLs depending upon release or debug build in the flutter app. Now I want to integrate FastLane for CI/CD and don't know how I can use --dart-define parameter from FastLane, as I will have to use Gradle build command from FastLane.

One possible solution is to use,

const bool isProduction = bool.fromEnvironment('dart.vm.product');

as told here https://stackoverflow.com/a/52820431/9917400

But, I don't want to use this as it can only differentiate b/w prod and dev. If in the future we use a staging server, we will have to again do changes.

Dhruv garg
  • 689
  • 7
  • 22

1 Answers1

2
import 'package:flutter/foundation.dart';

if (kReleaseMode) {
  Global.baseurl = "release";
} else if (kProfileMode) {
  Global.baseurl = "profile";
} else {
  Global.baseurl = "debug";
}

this worked for me

SoundwaveUwU
  • 138
  • 1
  • 2
  • 12
Dhruv garg
  • 689
  • 7
  • 22