简体   繁体   English

如何将 Flutter 移动应用迁移到 Flutter Web

[英]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 时要遵循的步骤:

  1. update build config according to the migration guide根据迁移指南更新构建配置

  2. replace all flutter imports with flutter_web用 flutter_web 替换所有颤振导入

  3. 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 )中的等效项替换它们

  4. 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:iodart:isolate的代码也不支持,需要重写。

Beginning with Flutter v1.10 , you can migrate your Flutter app to Web.从 Flutter v1.10开始,您可以将 Flutter 应用程序迁移到 Web。

  1. Enable web support by running:通过运行启用 Web 支持:

     flutter config --enable-web
  2. 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 .
  3. Check connected devices by running:通过运行检查连接的设备:

     flutter devices
  4. Run your app in chrome by running:通过运行以下命令在 chrome 中运行您的应用程序:

     flutter run -d chrome

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 Flutter 移动应用程序转换为 Web 应用程序 - How to convert Flutter Mobile app to Web App 如何在单击 flutter web 应用程序 url 时建议 Flutter Mobile 应用程序? - How to suggest Flutter Mobile app on clicking flutter web app url? 如何将我的 flutter web 应用程序迁移到新的 Google 身份服务? - How to migrate my flutter web app to the new Google Identity Services? Flutter 调味移动应用程序和 Flutter web - Flutter flavouring mobile app and Flutter web 如何使用 Flutter 使用客户端移动应用程序创建管理员 Web 应用程序 - How to create an admin Web app with client Mobile app using Flutter Flutter Web 应用程序无法在移动浏览器上运行。 如果在移动浏览器上运行flutter代码,如何调试错误? - Flutter web app not working on mobile browser. How to debug the error if running flutter code on mobile browser? 如何知道我的 Flutter Web 应用程序是在移动设备还是桌面设备上运行 - How to know if my flutter web app is running on mobile or desktop 如何屏蔽 flutter webView 中的广告(移动应用中的 web 页面) - How to block ads in a flutter webView ( web page in mobile app ) 如何在 flutter web 应用程序的移动浏览器中禁用旋转 - how to disable rotation in mobile browser in flutter web app 禁用 flutter web 应用程序的 crashlytics 并启用 flutter 移动应用程序 - Disable crashlytics for flutter web app and enable for flutter mobile app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM