getBluetoothState method

Future<BluetoothState> getBluetoothState()

Retrieves the current Bluetooth state.

Implementation

Future<BluetoothState> getBluetoothState() async {
  try {
    final result = await _methodChannel.invokeMapMethod<String, dynamic>(
      'getBluetooth',
    );
    if (result == null) {
      throw Exception('Failed to retrieve Bluetooth state.');
    }
    return BluetoothState.fromMap(result);
  } catch (e) {
    throw Exception('Error fetching Bluetooth state: $e');
  }
}