-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#14367Labels
a: existing-appsIntegration with existing apps via the add-to-app flowIntegration with existing apps via the add-to-app flowengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.
Description
When I use initWithEngine:nibName:bundle: to create FlutterViewController, and then setInitialRoute: ;I find it doesn't work; When I use window.defaultRouteName in main.dart I get '/'
This is the code:
// Appdelegate
FlutterEngine *engine = [[FlutterEngine alloc] initWithName:@"io.flutter" project:nil allowHeadlessExecution:YES];
self.engine = engine;
[self.engine runWithEntrypoint:nil];
// ViewController
FlutterEngine *flutterEngine = [(AppDelegate *)[[UIApplication sharedApplication] delegate] engine];
FlutterViewController* flutterViewController = [[FlutterViewController alloc] initWithEngine:flutterEngine nibName:nil bundle:nil];
[flutterViewController setInitialRoute:@"myApp"];// main.dart
void main() => runApp(_widgetForRoute(window.defaultRouteName));
Widget _widgetForRoute(String route) {
switch (route) {
case 'myApp':
return new MyApp();
case 'home':
return new HomePage();
default:
return Center(
child: Text('Unknown route: $route', textDirection: TextDirection.ltr),
);
}
}I always get a Text and content is ''Unknown route: /'
pejalo, leemcdole, yehot, 89jd, szotp and 18 more
Metadata
Metadata
Assignees
Labels
a: existing-appsIntegration with existing apps via the add-to-app flowIntegration with existing apps via the add-to-app flowengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.