BleMethodChannelRouter class

Fans native callbacks out to every Dart listener so that BLE operations never replace each other's receivers.

Flutter permits one incoming handler per method channel, and all central callbacks share a single channel. This router installs that one handler and republishes every incoming MethodCall on a shared broadcast stream. Each operation (scan, connect, service discovery, adapter status, and so on) derives its own stream by filtering on the callback's method name. Starting one operation therefore never silences the stream returned by another.

Untargeted error callbacks

The native layers report some failures with a bare error callback that names neither a device nor an operation. Because the Dart side cannot tell which operation such an error belongs to, it is delivered only to the stream of the most recently started operation that reports errors (see operationCalls). This matches the routing these errors had before per-method fan-out existed.

Constructors

BleMethodChannelRouter.forChannel(MethodChannel channel)
Returns the shared router, installing the native handler on first access.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

callsNamed(String method) → Stream<MethodCall>
Returns native callbacks whose method name equals method.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
operationCalls(String method) → Stream<MethodCall>
Returns native callbacks named method, plus untargeted error callbacks while this is the newest operation.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

errorMethod → const String
The method name native code uses for failures that identify neither a device nor an operation.