I'm using flutter module to add some screens in my native iOS app. same thing is used on android side as well. Now I want to add dev, prod flavour to the app. I've managed to do so in flutter module and I can launch it as well using terminal
flutter run --flavor dev/prod
this works as expected. But now I want to trigger this from my native app. I've created same schemas in iOS side but it always launches the last generated flavour of flutter module not the one I'm trying to run.
I've already read this git issue. It has no solution and the last commit just says Yeah you can do it but not how.
I ended up using vm:entry-point pragma to control the entry point of flutter module and assign needed value to build context. Which can be accessed through out the app whenever it is needed.
@pragma('vm:entry-point')
Future<void> devMain() async {
await mainSetup();
runApp(AppConfig(appEnvironment: AppEnvironment.dev, child: MyApp()));
}
@pragma('vm:entry-point')
Future<void> main() async {
await mainSetup();
runApp(AppConfig(appEnvironment: AppEnvironment.prod, child: MyApp()));
}
Now we can run these entry points from native app using below code
let engine = FlutterEngine(name: "com.coforge.my_router")
-> engine.run(withEntrypoint: "devMain")
-> engine.run(withEntrypoint: nil)