首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >共享代码库不可能用于Flutter中的Web和Mobile (?)

共享代码库不可能用于Flutter中的Web和Mobile (?)
EN

Stack Overflow用户
提问于 2019-06-03 13:37:08
回答 2查看 252关注 0票数 0

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

代码语言:javascript
复制
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看起来像这样:

代码语言:javascript
复制
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) 
EN

回答 2

Stack Overflow用户

发布于 2019-06-04 15:09:33

正如评论中提到的,目前不可能在一个项目中共享web和本机代码库。如果你读过这篇文章,请参考this link。它提供了Flutter团队可用的解决方法的说明。

票数 0
EN

Stack Overflow用户

发布于 2020-08-18 00:15:58

我正在研究的一个解决方案是通过dart代理在flutter中使用原生javascript。将javascript代码复制到Web/src下的index.html文件中。script src javascript代码。在你的main.dart中导入dart:js作为js并使用js.context.callMethod(‘你的函数’,你的参数来调用javascript方法。

我不得不使用javascript,因为flutter不支持chrome的qr阅读器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56421668

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档