BleConnectionEvent class

A single connection lifecycle update for a BLE peripheral, carrying the new state and, when the state reflects a problem, the failure detail that explains it.

Why an event rather than a bare state

Connection state alone cannot answer "why did this fail?". Both Apple and Android platforms surface failure detail (a CBError/CBATTError on Apple, a GATT/HCI status integer on Android) alongside the state change, but a plain BleConnectionState enum has nowhere to carry it. BleConnectionEvent couples the state with an optional BleConnectionFailure so that the reason travels in-band with the state it describes, guaranteeing correct ordering and eliminating the need for a parallel error channel.

When failure is populated

Use isFailure as a convenience to detect any event that carries failure detail.

Constructors

BleConnectionEvent({required BleConnectionState state, BleConnectionFailure? failure})
Creates a BleConnectionEvent.
const
BleConnectionEvent.fromMap(Map<Object?, Object?> map)
Creates a BleConnectionEvent from the map sent across the method channel by the native platform.
factory

Properties

failure → BleConnectionFailure?
The failure detail associated with this event, or null when the event does not represent a failure.
final
hashCode → int
The hash code for this object.
no setterinherited
isFailure → bool
Whether this event carries failure detail.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
state → BleConnectionState
The connection state reported by this event.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

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