0

当我尝试在 Flutter 中合并移动和 Web 代码库时,我看到以下错误:

webdev could not run for this project.
This version of webdev does not support the `build_daemon` protocol used by your version of `build_runner`.
Please add a dev dependency on `build_daemon` with constraint: >=1.0.0 <2.0.0
pub finished with exit code 78

我的pubspec.yaml样子是这样的:

environment:
  sdk: '>=2.2.0 <3.0.0'

dependencies:
  flutter_web: any
  flutter_web_ui: any

dev_dependencies:
  # Enables the `pub run build_runner` command
  build_runner: ^1.1.2
  # Includes the JavaScript compilers
  build_web_compilers: ^1.0.0

# 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```

I'm confused about how can "shared code" can really be "shared" across multi-platform in Flutter (shared codebase being the most important feature in Flutter pitch) 
4

2 回答 2

0

正如评论中提到的,目前无法在一个项目中共享 Web 和本机代码库。如果您遇到此帖子,请参阅此链接。它有关于 Flutter 团队可用的解决方法的说明。

于 2019-06-04T07:09:32.753 回答
0

我正在研究的一种解决方案是通过 dart 代理在 Flutter 中使用原生 JavaScript。将您的 JavaScript 代码复制到 Web/src 和 index.html 文件中。脚本 src javascript 代码。在你的 main.dart 导入 dart:js as js 并使用 js.context.callMethod('your function',[your parameters] 来调用 javascript 方法。

我也被迫使用 javascript,因为颤振不支持 chrome 的 qr 阅读器。

于 2020-08-17T16:15:58.353 回答