BluetoothDevice class

蓝牙设备摘要信息。

Android 的 id 通常为 MAC 地址;Linux 通常为 BlueZ Address 或 DBus object path; iOS/macOS 的 id 为 CoreBluetooth peripheral UUID;Web 的 id 为浏览器生成的站点内设备 ID, 且不公开真实蓝牙地址。

Constructors

BluetoothDevice({required String id, String? name, String? address, String? type, bool isConnected = false, bool isBonded = false, Map<String, dynamic> raw = const <String, dynamic>{}})
创建设备信息。
const
BluetoothDevice.fromMap(Map<String, dynamic> map)
从原生 Map 创建设备信息。
factory

Properties

address String?
设备地址,默认 null;iOS/macOS 通常不公开真实地址。
final
hashCode int
The hash code for this object.
no setterinherited
id String
设备标识。Android 通常为 MAC,Linux 通常为 BlueZ Address,iOS/macOS 为 peripheral UUID, Web 为浏览器生成 ID。
final
isBonded bool
是否已绑定/配对,默认 false;主要 Android 有意义。
final
isConnected bool
是否已连接,默认 false
final
name String?
设备名称,可能为空。
final
raw Map<String, dynamic>
原生完整字段,默认空 Map。
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String?
设备类型,默认 null
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() Map<String, dynamic>
转为可传给原生端的 Map。
toString() String
返回便于日志输出的设备摘要字符串。
override

Operators

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