如何将"Flutter for Web"转换为"Flutter for Mobile"?



我找到了如何迁移"移动动物"以" for web"的"颤动"。https://github.com/flutter/flutter_web/blob/master/docs/migration_guide.md

但是,我需要相反的方式。

我只尝试过" flutter run",当然,它运行不好。

我不明白在哪里替换。

name: my_app
version: 1.0.0
dependencies:
  ## REPLACE
  ## Update your dependencies to use `flutter_web`
  #flutter:
  #  sdk: flutter
  flutter_web: any
dev_dependencies:
  ## REPLACE
  ## Same goes for test packages
  #flutter_test:
  #  sdk: flutter
  flutter_web_test: any
  ## ADD
  ## Add these dependencies to enable the Dart web build system
  build_runner: ^1.2.2
  build_web_compilers: ^1.1.0
  test: ^1.3.4
## REMOVE
## For the preview, assets are handled differently. Remove or comment
## out this section. See `Assets` below for more details
# flutter:
#   uses-material-design: true
#   assets:
#     - asset/
#
#   fonts:
#   - family: Plaster
#     fonts:
#     - asset: asset/fonts/plaster/Plaster-Regular.ttf
## ADD
## flutter_web packages are not published to pub.dartlang.org
## These overrides tell the package tools to get them from GitHub
dependency_overrides:
  flutter_web:
    git:
      url: https://github.com/flutter/flutter_web
      path: packages/flutter_web
  flutter_web_ui:
    git:
      url: https://github.com/flutter/flutter_web
      path: packages/flutter_web_ui

我希望有一种迁移的方法,即使这很复杂。我试图迁移的是下面。https://github.com/flutter/flutter_web/tree/master/examples/gallery

是的,一个人认为您可以做到。

您应该做的第一件事是:将pubspec.yaml文件更新为类似的内容:

dependencies:
  flutter:
    sdk: flutter
dev_dependencies:
  flutter_test:
   sdk: flutter
flutter:
  uses-material-design: true

运行flutter packages get后,错误将来自任何地方,所以您必须在lib目录下更新每个文件中的每个导入。将是这样的:

import 'package:flutter_web/material.dart' to import 'package:flutter/material.dart';

之后,您必须再次创建项目才能获取Android和iOS项目目录。

要这样做,您必须转到终端,导航到项目的根目录并运行此命令flutter create .

最后,只需运行您的项目。

相关内容

  • 没有找到相关文章

最新更新