美文网首页
Flutter iOS启动跳native页面在跳进flutter

Flutter iOS启动跳native页面在跳进flutter

作者: fordG | 来源:发表于2020-08-20 15:08 被阅读0次
    • 我的需求时, 我刚进app的时候需要进入一个原生页面获取我需要的一些信息,这个需求的实现过程
    1. 自定义appDelegate
    #import <Flutter/Flutter.h>
    #import <UIKit/UIKit.h>
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (nonatomic, strong) UIWindow *window;
    @property (nonatomic, strong) FlutterEngine *flutterEngine;
    
    @end
    
    1. 跳到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;
    }
    
    1. 在你需要的地方去跳到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;
    }
    

    相关文章

      网友评论

          本文标题:Flutter iOS启动跳native页面在跳进flutter

          本文链接:https://www.haomeiwen.com/subject/mcosjktx.html