send<T> method
Send a command to native.
Implementation
Future<T?> send<T>(NativeCommand command) async {
try {
final result = await _channel.invokeMethod<T>(
'command',
command.toMap(),
).timeout(commandTimeout);
return result;
} on TimeoutException catch (e, stackTrace) {
Error.throwWithStackTrace(
NativeBridgeException(
command: command,
message: 'Command timed out after ${commandTimeout.inSeconds}s',
code: 'TIMEOUT',
originalException: e,
),
stackTrace,
);
} on PlatformException catch (e, stackTrace) {
Error.throwWithStackTrace(
NativeBridgeException(
command: command,
message: e.message ?? 'Unknown error',
code: e.code,
originalException: e,
),
stackTrace,
);
}
}