FakeRfcommTransport class
A controllable RfcommTransport for tests.
- Implemented types
Constructors
- FakeRfcommTransport({required DeviceId device, required int? channel, required Uuid serviceUuid, int? maxPayloadSize})
Properties
- channel → int?
-
The channel passed to
openRfcomm(null if SDP-resolved).final - device → DeviceId
-
Which device this transport was opened for.
final
- flushCount ↔ int
-
Number of times flush was awaited.
getter/setter pair
- flushDrains ↔ bool
-
Whether flush models a real drain acknowledgement (Windows, Linux,
Android) by zeroing pendingWriteBytes once it resolves. Set false to
model the best-effort platforms (macOS/iOS), where flush resolves
immediately and the queue drains on its own time — tests then lower
pendingWriteBytes themselves to simulate the OS draining.
getter/setter pair
- flushError ↔ Object?
-
If set, flush throws this — models a dead-link flush failure
(Windows/Linux/Android throw a BluetoothWriteException there).
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
incoming
→ Stream<
Uint8List> -
Inbound bytes. Single-subscription; closes on disconnect (clean EOF).
no setteroverride
- maxPayloadSize ↔ int?
-
OS-advertised max single-write payload surfaced as
RfcommTransport.maxPayloadSize. Mutable so tests can model any
platform: null (the default) for Windows/Linux/iOS, ~1011 for a macOS
RFCOMM MTU, ~990 for an Android max-transmit-packet-size.
getter/setter pairoverride-getter
- pendingWriteBytes ↔ int
-
Bytes accepted by send but not yet "handed to the OS". Grows by
data.lengthon every send; returns to 0 on a successful flush when flushDrains is true. Also settable, so tests can script arbitrary queue depths and drain timelines.getter/setter pairoverride-getter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sent
→ List<
Uint8List> -
Everything written via send, in order.
final
- serviceUuid → Uuid
-
The service UUID requested.
final
- state → ConnectionState
-
Current state.
no setteroverride
-
stateChanges
→ Stream<
ConnectionState> -
Connection-state transitions for this channel.
no setteroverride
Methods
-
close(
) → Future< void> -
Closes the channel. Idempotent.
override
-
deliver(
List< int> bytes) → void -
Pushes
bytesto the connection's input stream as if received. -
dropPeer(
) → void - Simulates the peer dropping the link. Mirrors real backends, which close both the state and incoming streams on a peer-initiated disconnect.
-
flush(
) → Future< void> -
Completes when all queued bytes have been handed to the OS.
override
-
nativeStats(
) → Map< String, int> - A snapshot of this transport's delivery counters.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
send(
Uint8List data) → void -
Queues
datafor transmission. Must return immediately without blocking; the platform drains the queue off the calling isolate.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited