runTransaction method
Future<TransactionCoordinatorOutcome?>
runTransaction(
- TransactionRequest request, {
- Map<
String, dynamic> ? config,
Runs a transaction through the native coordinator.
Returns null if the native path is not available,
signaling the caller to fall back to the Dart
coordinator.
The optional config map is passed to the native
handler to configure gateway transport creation.
When omitted, the native handler defaults to
payloadOnly mode.
Implementation
Future<TransactionCoordinatorOutcome?> runTransaction(
TransactionRequest request, {
Map<String, dynamic>? config,
}) async {
if (!await isAvailable()) {
SdkLogger.instance.info(SdkLogCategory.transaction, 'NativeCoordinatorAdapter: falling back to Dart coordinator');
return null;
}
SdkLogger.instance.info(SdkLogCategory.transaction, 'NativeCoordinatorAdapter: native transaction started');
try {
final resolvedConfig = await _resolveConfigForBridge(config);
final args = <String, dynamic>{
'request': request.toJson(),
};
if (resolvedConfig != null) args['config'] = resolvedConfig;
final result = await _channel
.invokeMapMethod<String, dynamic>(
'nativeRunTransaction',
args,
);
if (result == null) return null;
final outcome = _mapOutcome(result);
SdkLogger.instance.info(SdkLogCategory.transaction, 'NativeCoordinatorAdapter: native transaction completed', metadata: {'outcomeKind': outcome.kind.wire});
return outcome;
} catch (_) {
SdkLogger.instance.warn(SdkLogCategory.transaction, 'NativeCoordinatorAdapter: native transaction failed, falling back to Dart coordinator');
return null;
}
}