美文网首页
flutter_module iOS 集成步骤

flutter_module iOS 集成步骤

作者: Kpengs | 来源:发表于2022-08-15 16:50 被阅读0次

    flutter iOS 集成步骤

    1.集成flutter环境

    方法:https://doc.flutterchina.club/setup-macos/

    按网址步骤集成环境,flutter doctor成功并且可以运行一个flutter程序。

    2.clone flutter_module 文件到项目同级目录下

    如: image.png

    3.用ide(我用的androidstudo)打开flutter_module 执行 flutter clean - flutter pub get

    4.打开项目pod文件 加入代码

    flutter_application_path = '../flutter_module'
    
    load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
    
    install_all_flutter_pods(flutter_application_path)
    
    image.png

    5.执行 pod install

    pod成功后flutter就集成到了原生项目中

    6.使用方法

    导入BoostDelegate 并

    初始化

    // 初始化FlutterBoost
    
    BoostDelegate *delegate = [BoostDelegate sharedInstance];
    
    delegate.navigationController = [UINavigationController new];
    
    [[FlutterBoost instance] setup:application delegate:delegate callback:^(FlutterEngine *engine) {
    
    
    }];
    

    跳转代码

    FlutterBoostRouteOptions *options = [FlutterBoostRouteOptions new];
    
    // 此处填写的页面名称,需要在Flutter Module项目中main的路由表中有对应的路由名称,否则会导致匹配不上跳转失败
    
    options.pageName = @"aboutApp";
    
    options.arguments = @{@"animated": @(YES)};
    
    options.completion = ^(BOOL completion) {
    
    };
    
    [[FlutterBoost instance] open:options];
    
    options.onPageFinished = ^(NSDictionary *dic) {
    
    NSLog(@"%@", dic);
    
    };
    

    相关文章

      网友评论

          本文标题:flutter_module iOS 集成步骤

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