Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dart FFI: Binding C/C++/Go/Rust Libs For Dart #242

Open
Tracked by #352 ...
hhstore opened this issue Dec 3, 2020 · 10 comments
Open
Tracked by #352 ...

Dart FFI: Binding C/C++/Go/Rust Libs For Dart #242

hhstore opened this issue Dec 3, 2020 · 10 comments

Comments

@hhstore
Copy link
Owner

hhstore commented Dec 3, 2020

📖 Abstract:

  • ✅ 基于 C FFI, 把 C/C++/Rust 库 binding 成 Dart 库, 供 Dart 调用。

💯 Related:

@hhstore
Copy link
Owner Author

hhstore commented Dec 3, 2020

Dart FFI : 绑定其他语言(c/c++/go/rust)库使用

  • ✅ FFI(Foreign function interface)
  • ✅ dart 当前 lib 生态还不够丰富. 很多比较新的领域, 缺少 lib, 或者 lib 质量不够好.
  • ✅ 需要借用其他语言的 lib 资源.

需求场景:

  • ✅ 把成熟的 c/rust/zig/go 库 binding 给 dart 调用.

使用 Zig + FFI 配合 Flutter 方案:

dart 调用其他语言方案:

原生插件:

FFI(Foreign function interface):

dart 官方:

官方文档:

官方工具:

with wasm:

with Java:

官方示例:

持续关注:

FFI 实践:

ref:

lib:

@hhstore
Copy link
Owner Author

hhstore commented Dec 3, 2020

C++ + FFI => dart

问题:

待实践的项目:

image

项目使用列表:

https://developer.trustwallet.com/wallet-connect

@hhstore
Copy link
Owner Author

hhstore commented Dec 3, 2020

Go + FFI => dart

  • 不推荐使用 Go + CGo 的 FFI 方案.
  • 尽量选择 Rust + FFI 方案.

一些讨论:

方案:

mobile:

desktop:

项目实践:

go 的其他方案:

@Sunbreak
Copy link

Dart Native 同步/异步交互示例:https://github.com/Sunbreak/native_interop.tour

Cronet的Flutter插件工程:https://github.com/Sunbreak/cronet_flutter

微信:wk2311007
我主要在做Flutter PC相关工作,有个FFI群可以多多交流~

@hhstore
Copy link
Owner Author

hhstore commented Apr 16, 2021

Dart Native 同步/异步交互示例:https://github.com/Sunbreak/native_interop.tour

Cronet的Flutter插件工程:https://github.com/Sunbreak/cronet_flutter

微信:wk2311007
我主要在做Flutter PC相关工作,有个FFI群可以多多交流~

  • 多谢提供这个 lib. 我学习一下哈.
  • 顺便我又发现几个 rust ffi 支持 flutter 的 lib.
  • 你可以了解一下.
  • FFI 对 flutter 来说, 确实是非常重要的功能.

rust + ffi + dart:

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2021

@laojianzi
Copy link

一个非常好的实现 appflowy system design,目前看起来 rust 表现最好,但可惜我不会 rust,一直没发现 go 有很好的多平台方案,cgo 本身已经不简单了...

@hhstore
Copy link
Owner Author

hhstore commented Jun 5, 2022

一个非常好的实现 appflowy system design,目前看起来 rust 表现最好,但可惜我不会 rust,一直没发现 go 有很好的多平台方案,cgo 本身已经不简单了...

  • 对. 这个项目, 是个不错的案例.
  • rust + flutter 的典范.
  • go + cgo 的模式, 不适合作 core lib 层, 给其他语言跨平台复用.
  • core lib 跨平台, 还是建议使用 rust/c/c++.

This was referenced Jun 16, 2022
@hhstore hhstore changed the title Dart: FFI(Foreign function interface) - Binding C/C++/Go/Rust Libs For Dart Dart FFI: Binding C/C++/Go/Rust Libs For Dart Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants