0

In flutter a made a linux application. Is consumes an endoint that varies depending the environment I need to build for. For each environment I have a different main file:

  • For production I have a main-prod.dart
  • For staging I have a main-staging.dart
  • For local development I have a main-dev.dart All files are located into `./lib/ folder with the rest of source code

During building for desktop application via:

  • flutter build linux or
  • flutter build windows or
  • flutter build macos

During run I can provide via -t parameter for example for local development I run:

flutter run -t ./lib/main-dev.dart

But how on Chirst's sake I can do the same for buidling as well?

Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164

1 Answers1

0

In you case you can build your application via:

flutter ^device^ -t ^main_file^

Where ^device^ are one of the following:

  • windows
  • linux
  • macos

And the ^main_file^ is the one you use during flutter run` in your case you have theese commands to select from:

environment file windows linux macos
production main-prod.dart flutter build windows -t ./lib/main-prod.dart flutter build linux -t ./lib/main-prod.dart flutter build macos -t ./lib/main-prod.dart
development main-dev.dart flutter build windows -t ./lib/main-dev.dart flutter build linux -t ./lib/main-dev.dart flutter build macos -t ./lib/main-dev.dart
staging main-staging.dart flutter build windows -t ./lib/main-staging.dart flutter build linux -t ./lib/main-staging.dart flutter build macos -t ./lib/main-staging.dart
Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164