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-10-31 13:00:30 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
75c86de07f3c3d2b670c46be8dfb41eed5128efb
75c86de0
1 parent
1676ead6
fix a build issue
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
ios/Classes/MobileScanner.swift
macos/Classes/MobileScannerPlugin.swift
ios/Classes/MobileScanner.swift
View file @
75c86de
...
...
@@ -133,7 +133,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
}
/// Start scanning for barcodes
func
start
(
barcodeScannerOptions
:
BarcodeScannerOptions
?,
returnImage
:
Bool
,
cameraPosition
:
AVCaptureDevice
.
Position
,
torch
:
Bool
ean
,
detectionSpeed
:
DetectionSpeed
,
completion
:
@escaping
(
MobileScannerStartParameters
)
->
())
throws
{
func
start
(
barcodeScannerOptions
:
BarcodeScannerOptions
?,
returnImage
:
Bool
,
cameraPosition
:
AVCaptureDevice
.
Position
,
torch
:
Bool
,
detectionSpeed
:
DetectionSpeed
,
completion
:
@escaping
(
MobileScannerStartParameters
)
->
())
throws
{
self
.
detectionSpeed
=
detectionSpeed
if
(
device
!=
nil
)
{
throw
MobileScannerError
.
alreadyStarted
...
...
@@ -282,7 +282,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
}
if
(
device
.
torchMode
!=
torch
)
{
device
.
lockForConfiguration
()
try
device
.
lockForConfiguration
()
device
.
torchMode
=
torch
device
.
unlockForConfiguration
()
}
...
...
macos/Classes/MobileScannerPlugin.swift
View file @
75c86de
...
...
@@ -277,7 +277,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
// Turn on the torch if requested.
if
(
torch
)
{
do
{
self
.
toggleTorchInternal
(
.
on
)
try
self
.
toggleTorchInternal
(
.
on
)
}
catch
{
// If the torch could not be turned on,
// continue the capture session.
...
...
@@ -320,12 +320,18 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
// TODO: this method should be removed when iOS and MacOS share their implementation.
private
func
toggleTorchInternal
(
_
torch
:
AVCaptureDevice
.
TorchMode
)
throws
{
if
(
device
==
nil
||
!
device
.
hasTorch
||
!
device
.
isTorchAvailable
)
{
if
(
device
==
nil
||
!
device
.
hasTorch
)
{
return
}
if
#available(macOS 15.0, *)
{
if
(
!
device
.
isTorchAvailable
)
{
return
}
}
if
(
device
.
torchMode
!=
torch
)
{
device
.
lockForConfiguration
()
try
device
.
lockForConfiguration
()
device
.
torchMode
=
torch
device
.
unlockForConfiguration
()
}
...
...
Please
register
or
login
to post a comment