BleBondEvent class
A single bonding 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
Bonding state alone cannot answer "why did this fail?". Android surfaces a failure reason (an unbond reason code)
alongside the transition to an unbonded state, but a plain BleBondState enum has nowhere to carry it.
BleBondEvent couples the state with an optional BleBondFailure so that the reason travels in-band with the state
it describes, guaranteeing correct ordering and eliminating the need for a parallel error channel. This mirrors the
design of BleConnectionEvent for the connection lifecycle.
When failure is populated
- BleBondState.failed: failure is always present and describes why the bond attempt failed, to the extent the platform provides that information.
- All other states (BleBondState.none, BleBondState.bonding, BleBondState.bonded, BleBondState.unknown):
failure is
null.
Use isFailure as a convenience to detect any event that carries failure detail.
Constructors
- BleBondEvent({required BleBondState state, BleBondFailure? failure})
-
Creates a BleBondEvent.
const
-
BleBondEvent.fromMap(Map<
Object?, Object?> map) -
Creates a BleBondEvent from the map sent across the method channel by the native platform.
factory
Properties
- failure → BleBondFailure?
-
The failure detail associated with this event, or
nullwhen 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 → BleBondState
-
The bonding 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