main
1part of 'bluetooth_cubit.dart';
2
3/// State of the devices bluetooth module.
4@immutable
5sealed class BluetoothState {
6 /// Initialize state of the devices bluetooth module.
7 const BluetoothState();
8
9 /// Returns the [BluetoothState] instance for given [BluetoothAdapterState] enum state
10 factory BluetoothState.fromAdapterState(BluetoothAdapterState state) => switch(state) {
11 // Bluetooth permissions should always be granted on normal android
12 // devices. Users on non-standard android devices will know how to
13 // enable them. If this is not the case there will be bug reports.
14 BluetoothAdapterState.unauthorized => BluetoothStateUnauthorized(),
15 BluetoothAdapterState.unfeasible => BluetoothStateUnfeasible(),
16 BluetoothAdapterState.disabled => BluetoothStateDisabled(),
17 BluetoothAdapterState.initial => BluetoothStateInitial(),
18 BluetoothAdapterState.ready => BluetoothStateReady(),
19 };
20}
21
22/// No information on whether bluetooth is available.
23///
24/// Users may show a loading indication but can not assume bluetooth is
25/// available.
26class BluetoothStateInitial extends BluetoothState {}
27
28/// There is no way bluetooth will work (e.g. no sensor).
29///
30/// Options relating to bluetooth should not be shown.
31class BluetoothStateUnfeasible extends BluetoothState {}
32
33/// There is a bluetooth sensor but the app has no permission.
34class BluetoothStateUnauthorized extends BluetoothState {}
35
36/// The device has Bluetooth and the app has permissions, but it is disabled in
37/// the device settings.
38class BluetoothStateDisabled extends BluetoothState {}
39
40/// Bluetooth is ready for use by the app.
41class BluetoothStateReady extends BluetoothState {}