invokeSDKMethod<T> method
Future<T>
invokeSDKMethod<T>(
- String invokeMethodName, {
- dynamic parameters,
- bool isMappable = false,
- GenericTypeKey? genericTypeKey,
Implementation
Future<T> invokeSDKMethod<T>(String invokeMethodName,
{dynamic parameters,
bool isMappable = false,
GenericTypeKey? genericTypeKey}) async {
T? result;
await methodChannel
.invokeMethod(invokeMethodName, parameters)
.then((dynamic value) {
if (!isMappable) {
if (value is T) {
result = value;
} else {
result = null;
}
} else {
dynamic finalValue = genericTypeKey != null
? Mappings.makeGenericMapping(genericTypeKey, value)
: Mappings.makeMapping<T>(value as Map);
if (finalValue != null && finalValue is T) {
result = finalValue;
} else {
result = null;
}
}
}).catchError((e) {
result = null;
});
return Future.value(result);
}