BluetoothConnectPlatform class abstract

蓝牙插件的平台抽象层(Platform Interface)。

作用:定义 Android/iOS 等平台必须实现的统一接口;业务侧通过 BluetoothConnect 调用,不直接依赖本类的具体实现。

调用步骤(插件内部):

  1. 默认实例指向 MethodChannelBluetoothConnect
  2. 测试时可 BluetoothConnectPlatform.instance = MockXxx() 替换实现
  3. 各平台在原生侧实现对应 MethodChannel / EventChannel 方法
Inheritance
  • Object
  • PlatformInterface
  • BluetoothConnectPlatform
Implementers

Constructors

BluetoothConnectPlatform()
创建平台接口实例,并绑定校验用 token。

Properties

connectionState Stream<String>
连接状态事件流。
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scanResults Stream<List<BluetoothDevice>>
扫描结果事件流。
no setter

Methods

connect(String deviceId) Future<void>
连接指定设备。
disconnect() Future<void>
断开当前连接。
isAvailable() Future<bool>
检测蓝牙硬件是否可用。
isOn() Future<bool>
检测蓝牙是否已开启。
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startScan({Duration timeout = const Duration(seconds: 10)}) Future<void>
开始 BLE 扫描。
stopScan() Future<void>
停止 BLE 扫描。
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

instance BluetoothConnectPlatform
当前生效的平台实现(默认 MethodChannel)。
getter/setter pair