How I can select which main file I must build in flutter during a release of a desktop application? - flutter

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?

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

Related

flutter: split-debug-info Don't work for web project?

when I use the command on windows build everything is ok:
flutter build windows --split-debug-info=mySoftware/symbols
When I use the same command to web build i get the message:
flutter build web--split-debug-info=profept_client/symbols
**`Could not find an option named "split-debug-info".`**
why I can't run this command o flutter web?

How to add mac os support to a flutter package project?

I have tried running the terminal command:
flutter config --enable-macos-desktop
but it gives me error:
The "--platforms" argument is not supported in package template
for an existing project just run
flutter create --platforms=macos .
See also here some official docs from the flutter website:
https://docs.flutter.dev/development/platform-integration/desktop#add-desktop-support-to-an-existing-flutter-app
I have found work around:
copy mac os folder from a new natural flutter project(non-package):
open terminal & run:
cd example/macos
3.run:
pod install
then
flutter run

The flutter project has been configured with flavor

The flutter project has been configured with flavor. When I run the project natively from Android, how do I specify the flutter program entry file?
An example to run a flavor:
flutter run --flavor prod -t lib/main_prod.dart
--flavor prod after the --flavor option you need to provide the flavor's name as it is declared.
-t lib/main_prod.dart the -t flag is the entry file target.

Flutter build AAR targeting dev and prod flavors (build variants)

I have set up different build variants like dev and staging and production.
I run local debug mode with command- flutter run -t lib/main_dev.dart
similarly, the production build command
- flutter build --apk -t lib/main_prod.dart --release
But AAR builds flutter build aar -t lib/main_prod.dart --release doesn't work?
is anything extra work needed for AAR builds?

Webdev serve : Can't load Kernel binary: Invalid kernel binary format version. No active package webdev

I want to display my mobile application on the web using Flutter. So, I have done the steps to make it.
But,when use webdev serve in command I get an error.
Can't load Kernel binary: Invalid kernel binary format version.
No active package webdev
I attach the photo below:
How I solve this problem? Thank you
Perhaps you have followed rather outdated instructions. webdev is not used anymore.
At the moment, this instruction is relevant.
flutter channel beta
flutter upgrade
flutter config --enable-web
flutter create myapp
cd myapp
flutter run -d chrome
To add web support to an existing project, run the following command in a terminal from the root project directory:
flutter create .