





























flutter boost 5.0.2 集成
背景:
直接下载了flutter boost main,所有代码。iOS项目构建不通过。
flutter boost
FlutterBoost 5.0.0 虽然是一个官方发布的正式版本,但它所属的版本区间 [4.5.0, 5.0.0) 被官方定义为了专用于适配鸿蒙(HarmonyOS)的版本
所以需降级到 4.3.2, 或者升级到 5.0.2
升级到5.0.2之后
先是
flutter 项目本身的依赖冲突,
使用 flutter outdated,
flutter pub upgrade --major-versions,
处理flutter 项目依赖冲突。
再重新安装 相关依赖。
然后pod install iOS项目。
报错:
pod install
Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "image_picker_ios":
In Podfile:
image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
Specs satisfying the `image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)` dependency were found, but they required a higher minimum deployment target.
其实是podfile 中的image_picker_ios和 platatform :ios, '11.0'冲突了。
需要升级配置platatform :ios, '15.0'
问题解决
之后,构建 XCode中 workspace.
发现:
很多flutter错误,可以查看Xcode编译错误:
lib/case/bottom_navigation_bar_demo.dart:80:12: Error: The method 'WebView' isn't defined for the type 'Test1'.
- 'Test1' is from 'package:flutter_boost_example/case/bottom_navigation_bar_demo.dart' ('lib/case/bottom_navigation_bar_demo.dart').
Try correcting the name to the name of an existing method, or defining a method named 'WebView'.
return WebView(
^^^^^^^
lib/case/webview_flutter_demo.dart:106:36: Error: The method 'WebView' isn't defined for the type 'WebViewExampleState'.
- 'WebViewExampleState' is from 'package:flutter_boost_example/case/webview_flutter_demo.dart' ('lib/case/webview_flutter_demo.dart').
Try correcting the name to the name of an existing method, or defining a method named 'WebView'.
child: WebView(
^^^^^^^
lib/case/simple_webview_demo.dart:20:12: Error: The method 'WebView' isn't defined for the type 'SimpleWebViewState'.
- 'SimpleWebViewState' is from 'package:flutter_boost_example/case/simple_webview_demo.dart' ('lib/case/simple_webview_demo.dart').
Try correcting the name to the name of an existing method, or defining a method named 'WebView'.
return WebView(
^^^^^^^
lib/case/platform_view_perf.dart:123:30: Error: The method 'WebView' isn't defined for the type 'PlatformViewPerfState'.
- 'PlatformViewPerfState' is from 'package:flutter_boost_example/case/platform_view_perf.dart' ('lib/case/platform_view_perf.dart').
Try correcting the name to the name of an existing method, or defining a method named 'WebView'.
child: WebView(initialUrl: url),
^^^^^^^
Target kernel_snapshot_program failed: Exception
Failed to package /Users/jarvis/Documents/Projects26/FlutterProjects/flutter_boost-5.0.2/example.
Command PhaseScriptExecution failed with a nonzero exit code
排查后发现,还是 webview_flutter 的问题。
webview 示例中的版本都废弃了,官方使用了WebViewController,
使用阿里的灵码搞定。
lib/case/bottom_navigation_bar_demo.dart
lib/case/platform_view_perf.dart
lib/case/webview_flutter_demo.dart
lib/case/simple_webview_demo.dart
这四个文件中关于WebView的代码,全部替换为:
//lib/case/simple_webview_demo.dart 中
final String viewType = '<simple-text-view>';
//添加
late final WebViewController controller;
@override
void initState() {
super.initState();
controller = WebViewController() //添加
..setJavaScriptMode(JavaScriptMode.unrestricted) //添加
..loadRequest(Uri.parse(url)); //添加
// Enable virtual display.
// if (Platform.isAndroid) WebView.platform = AndroidWebView();
}
child: WebView( //删除
initialUrl: url, //删除
child: WebViewWidget( //添加
controller: controller, //添加
//以下3个文件中,有类似操作
lib/case/bottom_navigation_bar_demo.dart
lib/case/platform_view_perf.dart
lib/case/webview_flutter_demo.dart
之后再运行 fultter:
flutter pub get
// 可选
flutter build ios //如果证书配置不正确,会失败。
xCode:
pod install
build.
项目成功运行。

此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。