I use more than one dart main
file in my lib folder for passing different app configuration depending on server each will use.
Example of main_dev.dart
void main() async {
FlavorConfig(
flavorName: 'test',
values: {
'BASE_URL': 'http://$MY_IP:9002/graphql',
'WS_URL': 'ws://$MY_IP:9002/graphql',
},
);
await runApp(ProviderApp());
}
For now I have main_test.dart
and main_live.dart
and everything works fine when building android app.
Example I use the following command to build test app.
flutter build apk --obfuscate --split-debug-info=./build/app/outputs/symbols lib/main_test.dart
Note the last part lib/main_test.dart
I specify which file I intend to use and it works really well for building android app.
But I tried similar thing for web and I get the following error as it seems to me building web app needs main.dart
.
Target dart2js failed: Exception: .dart_tool/flutter_build/11c1feed0a867bb072ab6c7b64967a31/main.dart:8:8: Error: Error when reading 'lib/main.dart': Error reading 'lib/main.dart' (The system cannot find the file specified. ) import 'package:my_amazing_app/main.dart' as entrypoint; ^ .dart_tool/flutter_build/11c1feed0a867bb072ab6c7b64967a31/main.dart:13:3: Error: Method not found: 'main'. entrypoint.main(); ^^^^ Error: Compilation failed.
Compiling lib\main.dart for the Web...
20.3s Exception: Failed to compile application for the Web.
How can can specify the file I want in command for web too?.
I have tried the following without success flutter build web lib/main_test.dart