handle method
Handle a method call.
Implementation
Future<dynamic> handle(FfiMethodCall methodCall) async {
var recvPort = ReceivePort();
var map = <String, Object?>{
'method': methodCall.method,
'arguments': methodCall.arguments,
};
if (_debug) {
print('send $map');
}
map['sendPort'] = recvPort.sendPort;
sendPort.send(map);
var response = await recvPort.first;
if (_debug) {
print('recv $response');
}
if (response is Map) {
var error = response['error'];
if (error is Map) {
throw SqfliteFfiException(
code: error['code'] as String,
message: error['message'] as String,
details: (error['details'] as Map?)?.cast<String, Object?>(),
resultCode: error['resultCode'] as int?);
}
return response['result'];
}
return null;
}