getConnectionState method

  1. @override
Future<BluetoothConnectionState> getConnectionState(
  1. String deviceId
)
override

实现 FlutterBluetoothPluginPlatform.getConnectionState

Web 根据已知设备的 gatt.connected 属性返回连接状态。

Implementation

@override
Future<BluetoothConnectionState> getConnectionState(String deviceId) async {
  await _authorizedDevices();
  return _knownDevices[deviceId]?.gatt?.connected == true
      ? BluetoothConnectionState.connected
      : BluetoothConnectionState.disconnected;
}