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-12-29 11:46:31 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
66f88993bf8f62c491342967834c080478869a26
66f88993
1 parent
22709395
cherry pick available cameras into new implementation
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
1 deletions
lib/src/method_channel/mobile_scanner_method_channel.dart
lib/src/mobile_scanner_controller.dart
lib/src/mobile_scanner_view_attributes.dart
lib/src/objects/mobile_scanner_state.dart
lib/src/method_channel/mobile_scanner_method_channel.dart
View file @
66f8899
...
...
@@ -264,6 +264,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
_textureId
=
textureId
;
final
int
?
numberOfCameras
=
startResult
[
'numberOfCameras'
]
as
int
?;
final
bool
hasTorch
=
startResult
[
'torchable'
]
as
bool
?
??
false
;
final
Map
<
Object
?,
Object
?>?
sizeInfo
=
...
...
@@ -279,7 +280,11 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
size
=
Size
(
width
,
height
);
}
return
MobileScannerViewAttributes
(
hasTorch:
hasTorch
,
size:
size
);
return
MobileScannerViewAttributes
(
hasTorch:
hasTorch
,
numberOfCameras:
numberOfCameras
,
size:
size
,
);
}
@override
...
...
lib/src/mobile_scanner_controller.dart
View file @
66f8899
...
...
@@ -239,6 +239,7 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
);
value
=
value
.
copyWith
(
availableCameras:
viewAttributes
.
numberOfCameras
,
cameraDirection:
effectiveDirection
,
isInitialized:
true
,
isRunning:
true
,
...
...
lib/src/mobile_scanner_view_attributes.dart
View file @
66f8899
...
...
@@ -4,12 +4,16 @@ import 'dart:ui';
class
MobileScannerViewAttributes
{
const
MobileScannerViewAttributes
({
required
this
.
hasTorch
,
this
.
numberOfCameras
,
required
this
.
size
,
});
/// Whether the current active camera has a torch.
final
bool
hasTorch
;
/// The number of available cameras.
final
int
?
numberOfCameras
;
/// The size of the camera output.
final
Size
size
;
}
...
...
lib/src/objects/mobile_scanner_state.dart
View file @
66f8899
...
...
@@ -8,6 +8,7 @@ import 'package:mobile_scanner/src/mobile_scanner_exception.dart';
class
MobileScannerState
{
/// Create a new [MobileScannerState] instance.
const
MobileScannerState
({
required
this
.
availableCameras
,
required
this
.
cameraDirection
,
required
this
.
isInitialized
,
required
this
.
isRunning
,
...
...
@@ -20,6 +21,7 @@ class MobileScannerState {
/// Create a new [MobileScannerState] instance that is uninitialized.
const
MobileScannerState
.
uninitialized
(
CameraFacing
facing
)
:
this
(
availableCameras:
null
,
cameraDirection:
facing
,
isInitialized:
false
,
isRunning:
false
,
...
...
@@ -28,6 +30,11 @@ class MobileScannerState {
zoomScale:
1.0
,
);
/// The number of available cameras.
///
/// This is null if the number of cameras is unknown.
final
int
?
availableCameras
;
/// The facing direction of the camera.
final
CameraFacing
cameraDirection
;
...
...
@@ -55,6 +62,7 @@ class MobileScannerState {
/// Create a copy of this state with the given parameters.
MobileScannerState
copyWith
({
int
?
availableCameras
,
CameraFacing
?
cameraDirection
,
MobileScannerException
?
error
,
bool
?
isInitialized
,
...
...
@@ -64,6 +72,7 @@ class MobileScannerState {
double
?
zoomScale
,
})
{
return
MobileScannerState
(
availableCameras:
availableCameras
??
this
.
availableCameras
,
cameraDirection:
cameraDirection
??
this
.
cameraDirection
,
error:
error
,
isInitialized:
isInitialized
??
this
.
isInitialized
,
...
...
Please
register
or
login
to post a comment