The official Adding a Flutter screen to an iOS app documentation suggests that starting with Flutter version 1.22, an initial route can be set for Flutter when constructing the FlutterViewController:
let flutterEngine = FlutterEngine()
// FlutterDefaultDartEntrypoint is the same as nil, which will run main().
engine.run(
withEntrypoint: FlutterDefaultDartEntrypoint, initialRoute: "/onboarding")
But when following these instructions, the build fails with an error:
Undefined symbol: _FlutterDefaultDartEntrypoint
As the comment in the above code example suggests, "FlutterDefaultDartEntrypoint is the same as nil, which will run main".
So substituting
FlutterDefaultDartEntrypoint
withnil
solves the issue:For running anything other than the default
main()
method, the following can be used:This will look for an
otherMain()
method in theother_file.dart
file.