flutter_module iOS 集成步骤
2022-08-15 本文已影响0人
Kpengs
flutter iOS 集成步骤
1.集成flutter环境
方法:https://doc.flutterchina.club/setup-macos/
按网址步骤集成环境,flutter doctor成功并且可以运行一个flutter程序。
2.clone flutter_module 文件到项目同级目录下
如: image.png3.用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);
};