Flutter 和 Openlayers——包括 flutter 中的 js 库
Flutter and Openlayers - including js libraries in flutter
来自基于 js/cordova 的跨平台世界,我最近正在研究 flutter。所以我想知道直接在 flutter 中使用各种 js 库的选项。更具体地说,我有兴趣在 flutter 中使用 openlayers 库来创建具有各种绘图和编辑功能的多功能地图视图。所以我想知道有哪些选项可以包含它。
到目前为止我看到两种主要方式:
使用网络视图:
尽管没有原生的 webview 小部件,但在 flutter 中有一个插件(https://github.com/dart-flitter/flutter_webview_plugin)。我在这里看到的主要优势是使用 openlayers 库 "as it is",但是该插件还处于早期状态,我还没有看到在 webview 中建立 flutter 和 js 函数之间通信的方法。此外(这只是我的假设)使用 webview 可能比使用 dart 代码创建适当的小部件要慢。
正在创建自定义小部件:
我已经看到有一些方法可以使用 js 包(https://pub.dartlang.org/packages/js) and for typings js_facade_gen (https://github.com/dart-lang/js_facade_gen) like it is done with the chartjs library (https://github.com/google/chartjs.dart/). So similar to this it should be possible to automatically convert the openlayers lib to dart. The main issue however is to integrate this into flutter, since openlayers is using a html5 canvas if I'm correct. Also the chartjs.dart package does not giva any hints how to include it in a flutter app. I've also seen there is a leaflet plugin (https://github.com/apptreesoftware/flutter_map)将 js 代码直接转换为 dart,它正在创建自己的小部件,但是他们似乎是手动重写代码(?),这是针对 20.000 的开放者代码行并不是真正的选择 atm。
我知道这不是本网站的最佳问题格式,但我希望有人能就从哪里开始或如何实施提出一些建议或提示,尤其是对于第二个选项 - 第一个是更直接。或者,如果您能想到第三种选择,请继续,非常感谢您提供任何线索。
在 Flutter 中使用 JS 的唯一方法是使用 WebView。
Dart 仅为浏览器应用程序编译为 JS,对于 Flutter,它编译为本机机器代码。
convert js code direcly to dart, using package js
package JS 不转换 JS,它只是为 JS 函数创建代理以便能够从 Dart 调用它们,但这也仅在 Dart web 应用程序中受支持。
来自基于 js/cordova 的跨平台世界,我最近正在研究 flutter。所以我想知道直接在 flutter 中使用各种 js 库的选项。更具体地说,我有兴趣在 flutter 中使用 openlayers 库来创建具有各种绘图和编辑功能的多功能地图视图。所以我想知道有哪些选项可以包含它。
到目前为止我看到两种主要方式:
使用网络视图: 尽管没有原生的 webview 小部件,但在 flutter 中有一个插件(https://github.com/dart-flitter/flutter_webview_plugin)。我在这里看到的主要优势是使用 openlayers 库 "as it is",但是该插件还处于早期状态,我还没有看到在 webview 中建立 flutter 和 js 函数之间通信的方法。此外(这只是我的假设)使用 webview 可能比使用 dart 代码创建适当的小部件要慢。
正在创建自定义小部件: 我已经看到有一些方法可以使用 js 包(https://pub.dartlang.org/packages/js) and for typings js_facade_gen (https://github.com/dart-lang/js_facade_gen) like it is done with the chartjs library (https://github.com/google/chartjs.dart/). So similar to this it should be possible to automatically convert the openlayers lib to dart. The main issue however is to integrate this into flutter, since openlayers is using a html5 canvas if I'm correct. Also the chartjs.dart package does not giva any hints how to include it in a flutter app. I've also seen there is a leaflet plugin (https://github.com/apptreesoftware/flutter_map)将 js 代码直接转换为 dart,它正在创建自己的小部件,但是他们似乎是手动重写代码(?),这是针对 20.000 的开放者代码行并不是真正的选择 atm。
我知道这不是本网站的最佳问题格式,但我希望有人能就从哪里开始或如何实施提出一些建议或提示,尤其是对于第二个选项 - 第一个是更直接。或者,如果您能想到第三种选择,请继续,非常感谢您提供任何线索。
在 Flutter 中使用 JS 的唯一方法是使用 WebView。
Dart 仅为浏览器应用程序编译为 JS,对于 Flutter,它编译为本机机器代码。
convert js code direcly to dart, using package js
package JS 不转换 JS,它只是为 JS 函数创建代理以便能够从 Dart 调用它们,但这也仅在 Dart web 应用程序中受支持。