Write native code using Dart. This package liberates you from native code and low performance channel.
Still under development!!!
This is the blue part(DartNative Bridge) in the picture below:
Flutter 1.20.2 (Dart 2.9.1)
Dart code:
// new Objective-C object.
RuntimeStub stub = RuntimeStub();
// Dart function will be converted to Objective-C block.
Block block = stub.fooBlock((NSObject a) {
print('hello block! ${a.toString()}');
return 101;
});
// invoke Objective-C block.
int result = block.invoke([stub]);
print(result);
// support built-in structs.
CGRect rect = stub.fooCGRect(CGRect(4, 3, 2, 1));
print(rect);
Objective-C code:
typedef int(^BarBlock)(NSObject *a);
@interface RuntimeStub
- (CGRect)fooCGRect:(CGRect)rect;
- (BarBlock)fooBlock:(BarBlock)block;
@end- 告别 Flutter Channel,调用 Native API 仅需一行代码!
- 如何实现一行命令自动生成 Flutter 插件
- 用 Dart 来写 Objective-C 代码
- 谈谈 dart_native 混合编程引擎的设计
- DartNative Memory Management: Object
- DartNative Memory Management: C++ Non-Object
- DartNative Struct
- 在 Flutter 中玩转 Objective-C Block
- Passing Out Parameter in DartNative
- Unit test.
- Documents.
