我有一个用flutter编写的移动应用程序,我想将其转换为flutter_web应用程序(尚无法集成flutter_web应用程序)。 我目前在打包方面遇到问题。
我已按照本网站https://www.codemitter.com/how-to-add-web-counterpart-in-an-existing-flutter-project/
中列出的说明进行操作我遇到以下错误
webdev could not run for this project.
You have a dependency on `cached_network_image` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `cloud_firestore` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `cupertino_icons` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `firebase_core` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `flutter` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `path_provider` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
You have a dependency on `sqflite` which is not supported for flutter_web tech preview. See https://flutter.dev/web for more details.
pub finished with exit code 78
以下插件的flutter_web版本是什么? 如何手动/自动更改flutter_web支持的这样的插件?
答案 0 :(得分:1)
插件为not yet supported on flutter_web
,我们尚无迁移故事的详细信息。调用本机Java或Swift代码的插件将无法自动迁移。导入dart:io
或dart:isolate
的任何代码也不受支持,因此需要重写。
答案 1 :(得分:1)
从Flutter v1.10
开始,您可以将Flutter应用迁移到Web。
运行以下命令启用Web支持:
flutter config --enable-web
现在,如果要创建一个新项目,则可以运行
flutter create project_name
或者如果要将现有的迁移到Web,请运行
flutter create .
通过运行以下命令检查连接的设备:
flutter devices
通过运行以下命令在chrome中运行您的应用程序:
flutter run -d chrome
答案 2 :(得分:0)
迁移到Flutter Web时要遵循的步骤:
根据迁移指南更新构建配置
用flutter_web替换所有flutter导入
删除所有依赖于本地平台(android或ios)的插件,并用dart:html或纯dart网络库(https://pub.dev/web)的等效插件替换它们
使用依赖于flutter框架的分支非本机库,例如https://github.com/rrousselGit/provider/issues/82,您可能需要自己创建一个fork:https://github.com/kevmoo/provider/commit/bb739c96463347dd185331655e1d8895665172b9
步骤1.和2.是小菜一碟。但是3.和4.可能非常绘画。