BleConnectionFailure class

Describes why a BLE connection attempt failed or an established connection was lost unexpectedly.

Overview

A BleConnectionFailure accompanies a BleConnectionState.failed event and may accompany a BleConnectionState.disconnected event when the disconnection was not initiated by the application. It carries both a normalized, cross-platform category for writing recovery logic and the raw platform-specific detail (rawCode, domain, description) for logging and deep diagnosis.

Platform detail

The amount of detail available depends entirely on the underlying platform:

  • iOS / macOS (CoreBluetooth): rawCode is the NSError code (a CBError.Code or CBATTError.Code raw value), domain is the NSError domain (such as CBErrorDomain), and description is the error's localizedDescription. CoreBluetooth often delivers a nil error on a failed connection, in which case rawCode, domain, and description are all null and category is BleConnectionFailureCategory.unknown.
  • Android (BluetoothGatt): rawCode is the integer GATT/HCI status code from onConnectionStateChange (for example 19, 133, or 8), domain is "android_gatt", and description is a short human-readable label when one is known.

Because the raw values differ per platform, prefer branching on category for behavior and use the raw fields for logging and analysis.

Constructors

BleConnectionFailure({required BleConnectionFailureCategory category, String? platform, int? rawCode, String? domain, String? description})
Creates a BleConnectionFailure.
const
BleConnectionFailure.fromMap(Map<Object?, Object?> map)
Creates a BleConnectionFailure from the map sent across the method channel by the native platform.
factory

Properties

category → BleConnectionFailureCategory
The normalized, platform-agnostic classification of the failure.
final
description → String?
A human-readable description of the failure as provided by the platform, when available.
final
domain → String?
The platform-specific error domain or source of rawCode, when available.
final
hashCode → int
The hash code for this object.
no setterinherited
platform → String?
The host platform that reported the failure, such as "ios", "macos", or "android".
final
rawCode → int?
The raw, platform-specific numeric error code, when the platform provides one.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

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