sendRequest<T> method
Sends an RPC request to the isolate and returns the typed response future.
Implementation
Future<T> sendRequest<T>(
String operation,
Map<String, dynamic> params,
) async {
if (sendPort == null) {
throw StateError('IsolateRpcClient not ready: sendPort is null');
}
final int id = _nextId++;
final Completer<T> completer = Completer<T>();
_pending[id] = completer;
try {
sendPort!.send({'id': id, 'op': operation, ...params});
return await completer.future;
} catch (e) {
_pending.remove(id);
rethrow;
}
}