2

我有一个用 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上支持?

4

3 回答 3

4

迁移到 Flutter Web 时要遵循的步骤:

  1. 根据迁移指南更新构建配置

  2. 用flutter_web替换所有flutter导入

  3. 删除所有依赖于原生平台(android 或 ios)的插件,并将它们替换为 dart:html 或纯 dart 网络库(https://pub.dev/web)中的等价物

  4. 使用依赖于颤振框架的分叉非本地库,例如https://github.com/rrousselGit/provider/issues/82您可能需要像这样自己创建一个分叉: https ://github.com/kevmoo/提供者/提交/bb739c96463347dd185331655e1d8895665172b9

步骤 1. 和 2. 是小菜一碟。但是 3. 和 4. 可能非常有色彩。

于 2019-06-18T21:17:46.390 回答
2

尚不支持flutter_web插件,我们还没有关于迁移故事的详细信息。调用本机 Java 或 Swift 代码的插件将无法自动迁移。任何导入dart:iodart:isolate不受支持且需要重写的代码。

于 2019-06-11T03:59:22.273 回答
1

从 Flutter 开始v1.10,您可以将 Flutter 应用程序迁移到 Web。

  1. 通过运行启用 Web 支持:

    flutter config --enable-web
    
  2. 现在,如果你想创建一个新项目,你可以运行

    flutter create project_name
    

    或者如果您想将现有的迁移到网络,请运行

    flutter create .
    
  3. 通过运行检查连接的设备:

    flutter devices
    
  4. 通过运行以下命令在 chrome 中运行您的应用程序:

    flutter run -d chrome
    
于 2020-04-23T01:54:22.607 回答