main
1import 'package:blood_pressure_app/features/bluetooth/backend/bluetooth_state.dart';
2import 'package:flutter_blue_plus/flutter_blue_plus.dart' as fbp;
3
4/// Bluetooth adapter state parser for the 'flutter_blue_plus' package
5final class FlutterBluePlusStateParser extends BluetoothAdapterStateParser<fbp.BluetoothAdapterState> {
6 @override
7 BluetoothAdapterState parse(fbp.BluetoothAdapterState rawState) => switch (rawState) {
8 fbp.BluetoothAdapterState.unavailable => BluetoothAdapterState.unfeasible,
9 // Bluetooth permissions should always be granted on normal android
10 // devices. Users on non-standard android devices will know how to
11 // enable them. If this is not the case there will be bug reports.
12 fbp.BluetoothAdapterState.unauthorized => BluetoothAdapterState.unauthorized,
13 fbp.BluetoothAdapterState.on => BluetoothAdapterState.ready,
14 fbp.BluetoothAdapterState.off
15 || fbp.BluetoothAdapterState.turningOn
16 || fbp.BluetoothAdapterState.turningOff => BluetoothAdapterState.disabled,
17 fbp.BluetoothAdapterState.unknown => BluetoothAdapterState.initial,
18 };
19}