forked from edufolly/flutter_bluetooth_serial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBluetoothDeviceType.dart
59 lines (51 loc) · 1.91 KB
/
BluetoothDeviceType.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
part of flutter_bluetooth_serial;
class BluetoothDeviceType {
final int underlyingValue;
final String stringValue;
const BluetoothDeviceType.fromString(String string)
: this.underlyingValue = (string == 'unknown'
? 0
: string == 'classic'
? 1
: string == 'le'
? 2
: string == 'dual'
? 3
: -2 // Unknown, if not found valid
),
this.stringValue = ((string == 'unknown' ||
string == 'classic' ||
string == 'le' ||
string == 'dual' //
)
? string
: 'unknown' // Unknown, if not found valid
);
const BluetoothDeviceType.fromUnderlyingValue(int value)
: this.underlyingValue = ((value >= 0 && value <= 3)
? value
: 0 // Unknown, if not found valid
),
this.stringValue = (value == 0
? 'unknown'
: value == 1
? 'classic'
: value == 2
? 'le'
: value == 3
? 'dual'
: 'unknown' // Unknown, if not found valid
);
String toString() => 'BluetoothDeviceType.$stringValue';
int toUnderlyingValue() => underlyingValue;
static const unknown = BluetoothDeviceType.fromUnderlyingValue(0);
static const classic = BluetoothDeviceType.fromUnderlyingValue(1);
static const le = BluetoothDeviceType.fromUnderlyingValue(2);
static const dual = BluetoothDeviceType.fromUnderlyingValue(3);
operator ==(Object other) {
return other is BluetoothDeviceType &&
other.underlyingValue == this.underlyingValue;
}
@override
int get hashCode => underlyingValue.hashCode;
}