cancel method

bool cancel(
  1. String id, [
  2. String? reason
])

Cancel a pending request by id.

Implementation

bool cancel(String id, [String? reason]) {
  final pending = _pending.remove(id);
  if (pending == null) return false;
  pending.timer?.cancel();
  pending.completer.completeError(
    BridgeError(
      code: ErrorCode.requestCancelled,
      message: reason ?? 'Request $id cancelled',
    ),
  );
  return true;
}