invokeAsync<T> method
Future<T?>
invokeAsync<T>(
- String method, [
- Map<
String, dynamic> ? args, - NativeThread thread = NativeThread.ui
Invokes an asynchronous native method across the platform boundary.
Maps raw platform errors into typed BloomNativeException variants (BloomNativePermissionDeniedException, BloomNativeHardwareUnavailableException, etc.).
Example:
final result = await invokeAsync<Map<String, dynamic>>('fetchDetails', {'id': 42});
Implementation
Future<T?> invokeAsync<T>(
String method, [
Map<String, dynamic>? args,
NativeThread thread = NativeThread.ui,
]) async {
try {
final result = await _methodChannel?.invokeMethod<T>(
method,
args,
);
return result;
} on PlatformException catch (e, stack) {
throw _mapPlatformException(e, stack);
} catch (e, stack) {
if (e is BloomNativeException) rethrow;
throw BloomNativeOperationFailedException(
message: 'Native call "$name.$method" failed: $e',
details: args,
stackTrace: stack,
);
}
}