Flutter iOS启动跳native页面在跳进flutter
2020-08-20 本文已影响0人
fordG
- 我的需求时, 我刚进app的时候需要进入一个原生页面获取我需要的一些信息,这个需求的实现过程
- 自定义appDelegate
#import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) FlutterEngine *flutterEngine;
@end
- 跳到native页面
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[self initializeWithOptions: launchOptions];
[NOTIFYCENTER addObserver:self selector:@selector(startMyApp) name: BXAccountDidLoginSuccessNotification object:nil];
return YES;
}
- (FlutterEngine *)flutterEngine {
if(_flutterEngine == nil){
_flutterEngine = [[FlutterEngine alloc] initWithName: @"FlutterEngine" project: nil];
}
return _flutterEngine;
}
- 在你需要的地方去跳到flutter页面,好像可以指定router没研究
- (void)startMyApp{
[self.flutterEngine runWithEntrypoint: nil];
FlutterViewController *controller = [[FlutterViewController alloc] initWithEngine: self.flutterEngine nibName: nil bundle: nil];
[GeneratedPluginRegistrant registerWithRegistry: controller];
self.window.rootViewController = controller;
}