如何将Flutter移动应用迁移到Flutter网站

时间:2019-06-11 03:45:52

标签: flutter dart flutter-web

我有一个用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支持的这样的插件?

3 个答案:

答案 0 :(得分:1)

插件为not yet supported on flutter_web,我们尚无迁移故事的详细信息。调用本机Java或Swift代码的插件将无法自动迁移。导入dart:iodart:isolate的任何代码也不受支持,因此需要重写。

答案 1 :(得分:1)

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

  1. 运行以下命令启用Web支持:

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

    flutter create project_name
    

    或者如果要将现有的迁移到Web,请运行

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

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

    flutter run -d chrome
    

答案 2 :(得分:0)

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

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

  2. 用flutter_web替换所有flutter导入

  3. 删除所有依赖于本地平台(android或ios)的插件,并用dart:html或纯dart网络库(https://pub.dev/web)的等效插件替换它们

  4. 使用依赖于flutter框架的分支非本机库,例如https://github.com/rrousselGit/provider/issues/82,您可能需要自己创建一个fork:https://github.com/kevmoo/provider/commit/bb739c96463347dd185331655e1d8895665172b9

步骤1.和2.是小菜一碟。但是3.和4.可能非常绘画。