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
Julian Steenbakker
2023-12-04 21:39:33 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
133f5c23d95ca5b3759f59a5e0eaf50ac61a7395
133f5c23
1 parent
b748b3ca
feat: add available camera information in startcallback on android
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
7 deletions
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt
android/src/main/kotlin/dev/steenbakker/mobile_scanner/objects/MobileScannerStartParameters.kt
example/lib/barcode_scanner_controller.dart
lib/src/mobile_scanner.dart
lib/src/mobile_scanner_controller.dart
lib/src/objects/mobile_scanner_arguments.dart
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
View file @
133f5c2
...
...
@@ -240,6 +240,7 @@ class MobileScanner(
cameraProviderFuture.addListener({
cameraProvider = cameraProviderFuture.get()
val nrOfCameras = cameraProvider?.availableCameraInfos?.size
if (cameraProvider == null) {
mobileScannerErrorCallback(CameraError())
...
...
@@ -340,7 +341,8 @@ class MobileScanner(
if (portrait) width else height,
if (portrait) height else width,
camera?.cameraInfo?.hasFlashUnit() ?: false,
textureEntry!!.id()
textureEntry!!.id(),
nrOfCameras ?: 0
)
)
}, executor)
...
...
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt
View file @
133f5c2
...
...
@@ -178,7 +178,8 @@ class MobileScannerHandler(
result.success(mapOf(
"textureId" to it.id,
"size" to mapOf("width" to it.width, "height" to it.height),
"torchable" to it.hasFlashUnit
"torchable" to it.hasFlashUnit,
"nrOfCameras" to it.nrOfCameras
))
}
},
...
...
android/src/main/kotlin/dev/steenbakker/mobile_scanner/objects/MobileScannerStartParameters.kt
View file @
133f5c2
...
...
@@ -4,5 +4,6 @@ class MobileScannerStartParameters(
val width: Double = 0.0,
val height: Double,
val hasFlashUnit: Boolean,
val id: Long
val id: Long,
val nrOfCameras: Int
)
\ No newline at end of file
...
...
example/lib/barcode_scanner_controller.dart
View file @
133f5c2
...
...
@@ -47,6 +47,8 @@ class _BarcodeScannerWithControllerState
}
}
int
?
nrOfCameras
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
...
...
@@ -57,6 +59,12 @@ class _BarcodeScannerWithControllerState
return
Stack
(
children:
[
MobileScanner
(
onScannerStarted:
(
arguments
)
{
if
(
arguments
?.
nrOfCameras
!=
null
)
{
nrOfCameras
=
arguments
!.
nrOfCameras
;
setState
(()
{});
}
},
controller:
controller
,
errorBuilder:
(
context
,
error
,
child
)
{
return
ScannerErrorWidget
(
error:
error
);
...
...
@@ -146,7 +154,9 @@ class _BarcodeScannerWithControllerState
},
),
iconSize:
32.0
,
onPressed:
()
=>
controller
.
switchCamera
(),
onPressed:
nrOfCameras
!=
null
&&
nrOfCameras
!
<
2
?
null
:
()
=>
controller
.
switchCamera
(),
),
IconButton
(
color:
Colors
.
white
,
...
...
lib/src/mobile_scanner.dart
View file @
133f5c2
...
...
@@ -225,12 +225,12 @@ class _MobileScannerState extends State<MobileScanner>
return
Stack
(
alignment:
Alignment
.
center
,
children:
[
_scanner
(
value
.
size
,
value
.
webId
,
value
.
textureId
),
_scanner
(
value
.
size
,
value
.
webId
,
value
.
textureId
,
value
.
nrOfCameras
),
widget
.
overlay
!,
],
);
}
else
{
return
_scanner
(
value
.
size
,
value
.
webId
,
value
.
textureId
);
return
_scanner
(
value
.
size
,
value
.
webId
,
value
.
textureId
,
value
.
nrOfCameras
);
}
},
);
...
...
@@ -238,7 +238,7 @@ class _MobileScannerState extends State<MobileScanner>
);
}
Widget
_scanner
(
Size
size
,
String
?
webId
,
int
?
textureId
)
{
Widget
_scanner
(
Size
size
,
String
?
webId
,
int
?
textureId
,
int
?
nrOfCameras
)
{
return
ClipRect
(
child:
LayoutBuilder
(
builder:
(
_
,
constraints
)
{
...
...
lib/src/mobile_scanner_controller.dart
View file @
133f5c2
...
...
@@ -304,6 +304,7 @@ class MobileScannerController {
isStarting
=
false
;
return
startArguments
.
value
=
MobileScannerArguments
(
nrOfCameras:
startResult
[
'nrOfCameras'
]
as
int
?,
size:
size
,
hasTorch:
hasTorch
,
textureId:
kIsWeb
?
null
:
startResult
[
'textureId'
]
as
int
?,
...
...
lib/src/objects/mobile_scanner_arguments.dart
View file @
133f5c2
...
...
@@ -15,10 +15,15 @@ class MobileScannerArguments {
/// The texture id of the capture used internally if device is web.
final
String
?
webId
;
/// Indicates how many cameras are available.
/// Only available on Android
final
int
?
nrOfCameras
;
MobileScannerArguments
({
required
this
.
size
,
required
this
.
hasTorch
,
this
.
textureId
,
this
.
webId
,
this
.
nrOfCameras
});
}
...
...
Please
register
or
login
to post a comment