Flutter 集成原生问题集锦
- 如何在原有项目中去继成
作为moudle引入项目,通过pod 集成,之前是采用
flutter_application_path = './flutter_lib'
eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
新版本采用:# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
flutter_application_path = './flutter_lib'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'FlutterDemoSwift' do
Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
install_all_flutter_pods(flutter_application_path)
Pods for FlutterDemoSwift
pod 'Masonry', '1.1.0'
target 'FlutterDemoSwiftTests' do
inherit! :search_paths
# Pods for testing
end
target 'FlutterDemoSwiftUITests' do
# Pods for testing
end
end
- 集成遇到的问题
- 找不到shared_prefercen, 升级Flutter pod install,如果还是不行,删去pod库的东西,删除Podfile.lock,重新pod install 然后 install
- 关于项目原生项目给FLutter 传递参数,
- 参数传递的过程
MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
这个异常是在测试代码里使用shared_preferences导致的, 我晕 我没有这个方法啊,还在纳闷呢,原来 shared_prefercen在iOS 中存储数据是采用UserDefault 存储的
4.关于Android 中的返回键问题,采用
@Override
public void onBackPressed() {
if(this.flutterView!=null){
this.flutterView.popRoute();
}else {
super.onBackPressed();
}
}
5.关于 PlatformException(unregistered_view_type, trying to create a view with an unregistered type, unregistered view type: 'plugins.flutter.io/webview'
: GeneratedPluginRegistrant.register(with:flutterCon.pluginRegistry() )
iOS Swift 原生集成flutter demo 拿走不谢
链接:https://pan.baidu.com/s/1kIR5BzhFaEkj4LPL0rZmVw 密码:wcpj
网友评论