Navaron Bracke

add unavailable torch state

... ... @@ -4,7 +4,10 @@ enum TorchState {
off(0),
/// The flashlight is on.
on(1);
on(1),
/// The flashlight is unavailable.
unavailable(2);
const TorchState(this.rawValue);
... ... @@ -14,6 +17,8 @@ enum TorchState {
return TorchState.off;
case 1:
return TorchState.on;
case 2:
return TorchState.unavailable;
default:
throw ArgumentError.value(value, 'value', 'Invalid raw value.');
}
... ...
... ... @@ -7,6 +7,7 @@ void main() {
const values = <int, TorchState>{
0: TorchState.off,
1: TorchState.on,
2: TorchState.unavailable,
};
for (final MapEntry<int, TorchState> entry in values.entries) {
... ... @@ -18,7 +19,7 @@ void main() {
test('invalid raw value throws argument error', () {
const int negative = -1;
const int outOfRange = 2;
const int outOfRange = 3;
expect(() => TorchState.fromRawValue(negative), throwsArgumentError);
expect(() => TorchState.fromRawValue(outOfRange), throwsArgumentError);
... ... @@ -28,6 +29,7 @@ void main() {
const values = <TorchState, int>{
TorchState.off: 0,
TorchState.on: 1,
TorchState.unavailable: 2,
};
for (final MapEntry<TorchState, int> entry in values.entries) {
... ...