callNativeEvent static method
Implementation
static Future callNativeEvent(
int renderManagerId,
int rootId,
int nodeId,
String eventName,
bool useCapture,
bool useBubble,
Object params,
) async {
var stopwatch = Stopwatch();
stopwatch.start();
var eventU16 = eventName.toNativeUtf16();
LogUtils.i('Voltron::Bridge', 'ID:$nodeId, call native event $eventName');
var encodeParamsByteData = const StandardMessageCodec().encodeMessage(params);
if (encodeParamsByteData != null) {
var length = encodeParamsByteData.lengthInBytes;
final result = malloc<Uint8>(length);
final nativeParams = result.asTypedList(length);
nativeParams.setRange(
0,
length,
encodeParamsByteData.buffer.asUint8List(),
);
_RenderBridgeFFIManager.instance.callNativeEvent(
renderManagerId,
rootId,
nodeId,
eventU16,
useCapture,
useBubble,
result,
length,
);
free(result);
stopwatch.stop();
LogUtils.profile("callNativeEvent", stopwatch.elapsedMilliseconds);
} else {
LogUtils.e('Voltron::Bridge', 'call native event error, invalid params');
}
free(eventU16);
}