Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2023-11-08 15:17:39 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
db0345769ca858d4ee07021fa722ddabcd338c91
db034576
1 parent
0bf66ee3
add unavailable torch state
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
lib/src/enums/torch_state.dart
test/enums/torch_state_test.dart
lib/src/enums/torch_state.dart
View file @
db03457
...
...
@@ -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.'
);
}
...
...
test/enums/torch_state_test.dart
View file @
db03457
...
...
@@ -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
)
{
...
...
Please
register
or
login
to post a comment