callObjectMethod<T extends JObject> method
async call native method which return object
Implementation
Future<dynamic> callObjectMethod<T extends JObject>(String methodName,
{List? args,
List<String>? assignedSignature,
Thread thread = Thread.mainThread}) async {
String type = T.toString();
if (type == 'dynamic') {
throw 'callObject error. \n'
'Using callObject need specify the dart type.\n'
'And this dart class need extend jobject. \n'
'For example: callObject<JInteger>("getTest");';
}
final sig = getRegisterJavaClassSignature(type);
if (sig == null) {
throw 'callObject error. \n'
'Can not find signature in register map.\n'
'You should use @nativeJavaClass specify the java class.'
'See more in https://github.com/dart-native/dart_native/tree/master#usage.\n'
'Or you can just use call method to specify the return type,'
'like callMethod("getString", "Ljava/lang/String;")';
}
final convertor = getRegisterPointerConvertor(type);
return callMethod(methodName, sig,
args: args, assignedSignature: assignedSignature, thread: thread)
.then((value) => convertor!((value as JObject).pointer));
}