MethodChannelBluetoothConnect class

蓝牙插件的 MethodChannel / EventChannel 默认实现。

作用:把 Dart 侧 API 通过 Channel 转发到 Android/iOS 原生代码。

调用步骤(内部通信):

  1. MethodChannel bluetooth_connect:同步类请求(检测、扫描、连接)
  2. EventChannel bluetooth_connect/scan_results:推送扫描到的设备列表
  3. EventChannel bluetooth_connect/connection_state:推送连接状态变化
Inheritance

Properties

connectionEventChannel EventChannel
事件通道:持续接收连接状态。
final
connectionState Stream<String>
将原生连接状态事件解析为字符串流。
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
methodChannel MethodChannel
方法通道:调用原生 isAvailable / startScan / connect 等。
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scanEventChannel EventChannel
事件通道:持续接收扫描结果。
final
scanResults Stream<List<BluetoothDevice>>
将原生扫描事件解析为 BluetoothDevice 列表流。
no setteroverride

Methods

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

Operators

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