在Flutter Web中使用Flutter移动软件包 [英] Using flutter mobile packages in flutter web

查看:121
本文介绍了在Flutter Web中使用Flutter移动软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Flutter Web,但我想使用Flutter Web版本中可用于移动设备的一些软件包。 Flutter Web的发布外观看起来与Flutter Mobile的发布有所不同,但这并不是真正的问题。我担心的是,有可能将适用于移动设备的软件包添加到网络中。如果是,执行此操作的正确方法是什么?

I am using flutter web and I want to use some packages that are available for the mobile in the web version of flutter. The pubspec of flutter web look a bit different from that of flutter mobile but this is not the real problem. What I am concerned about is that is it possible to add the packages availble for mobile into that of the web. If yes, what is the proper way to do so?

推荐答案

目前(从2019年6月起)取决于移动操作系统的软件包。原因是移动设备上的插件使用平台渠道与Android和iOS平台相关的代码实现进行通信,这些实现以Java / kotlin(对于android)或objc / swift编写(对于iOS)。

This is not currently possible (as of June 2019) for any package which is dependent on the mobile OS. The reason for this is that the plugins on mobile use platform channels to communicate with platform-dependent code implementations for Android and iOS written in java/kotlin for android or objc/swift for iOS.

这些软件包在网络上运行的唯一方法是为它们编写特定于Web的实现,我认为它们将使用脚本编译的库或更可能使用某种JavaScript桥来调用相关的浏览器API。

The only way those packages would ever work on the web is if a web-specific implementation were written for them which I assume would either use an emscripten-compiled library or more likely some sort of javascript bridge to call the relevant browser APIs.

从网络杂乱无章的自述文件


flutter_web还没有插件系统。暂时,我们提供对dart:html,dart:js,dart:svg,dart:indexed_db和其他网络库的访问,这些访问使您可以访问绝大多数浏览器API。但是,希望这些库将被不同的插件API取代。

flutter_web does not have a plugin system yet. Temporarily, we provide access to dart:html, dart:js, dart:svg, dart:indexed_db and other web libraries that give you access to the vast majority of browser APIs. However, expect that these libraries will be replaced by a different plugin API.






任何是100%飞镖代码的插件,您都应该能够像飘飘一样将其包含在pubspec.yaml中-在依赖项


For any plugin that is 100% dart code, you should be able to just include it in your pubspec.yaml the same way you would in flutter - under dependencies.

这篇关于在Flutter Web中使用Flutter移动软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆