[英]How to migrate flutter mobile app to flutter web
I have a mobile app written with flutter and i would like to convert it into a flutter_web app (integrating flutter_web is not available yet).我有一个用 flutter 编写的移动应用程序,我想将它转换为 flutter_web 应用程序(集成 flutter_web 尚不可用)。 I'm currently having problems with packages.
我目前遇到包裹问题。
I have followed the instructions listed in this website https://www.codemitter.com/how-to-add-web-counterpart-in-an-existing-flutter-project/我已按照本网站https://www.codemitter.com/how-to-add-web-counterpart-in-an-existing-flutter-project/ 中列出的说明进行操作
I get the following errors我收到以下错误
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
are the flutter_web versions for the following plugins?以下插件的 flutter_web 版本是什么? how would one manually/automatically change such a plugin to be supported on flutter_web?
如何手动/自动更改此类插件以在 flutter_web 上支持?
Steps to follow while migration to Flutter Web:迁移到 Flutter Web 时要遵循的步骤:
update build config according to the migration guide根据迁移指南更新构建配置
replace all flutter imports with flutter_web用 flutter_web 替换所有颤振导入
remove all plugins that depend on native platforms (android or ios) and replace them with equivalents from dart:html or pure dart web libraries ( https://pub.dev/web )删除所有依赖于本机平台(android 或 ios)的插件,并用 dart:html 或纯 dart 网络库( https://pub.dev/web )中的等效项替换它们
use forked non-native libraries that depend on flutter framework, like this https://github.com/rrousselGit/provider/issues/82 you might need to create a fork yourself like this: https://github.com/kevmoo/provider/commit/bb739c96463347dd185331655e1d8895665172b9使用依赖于颤振框架的分叉非本地库,像这样https://github.com/rrousselGit/provider/issues/82你可能需要像这样自己创建一个分叉: https : //github.com/kevmoo/提供者/提交/bb739c96463347dd185331655e1d8895665172b9
Steps 1. and 2. are pice of cake.步骤 1. 和 2. 是小菜一碟。 But 3. and 4. might be very paintful.
但是 3. 和 4. 可能非常有色彩。
Plugins are not yet supported on flutter_web
and we don't yet have details on what the migration story will look like. flutter_web
尚不支持插件,我们还没有关于迁移故事的详细信息。 Plugins which call through to native Java or Swift code will not be possible to migrate automatically.调用本机 Java 或 Swift 代码的插件将无法自动迁移。 Any code which imports
dart:io
or dart:isolate
is also unsupported and would need to be rewritten.任何导入
dart:io
或dart:isolate
的代码也不支持,需要重写。
Beginning with Flutter v1.10
, you can migrate your Flutter app to Web.从 Flutter
v1.10
开始,您可以将 Flutter 应用程序迁移到 Web。
Enable web support by running:通过运行启用 Web 支持:
flutter config --enable-web
Now, if you want to create a new project you can run现在,如果你想创建一个新项目,你可以运行
flutter create project_name
or if you want to migrate your existing one to web, run或者,如果您想将现有的迁移到网络,请运行
flutter create .
Check connected devices by running:通过运行检查连接的设备:
flutter devices
Run your app in chrome by running:通过运行以下命令在 chrome 中运行您的应用程序:
flutter run -d chrome
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.