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 10:36:24 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d316b6a758364a77cc2ca770628ee956b4150020
d316b6a7
1 parent
5d73cb35
return instead of throw when toggling torch on Android
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
10 deletions
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerExceptions.kt
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt
macos/Classes/MobileScannerPlugin.swift
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
View file @
d316b6a
...
...
@@ -376,7 +376,7 @@ class MobileScanner(
*/
fun toggleTorch(enableTorch: Boolean) {
if (camera == null) {
throw TorchWhenStopped()
return
}
if (camera?.cameraInfo?.hasFlashUnit() == true) {
...
...
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerExceptions.kt
View file @
d316b6a
...
...
@@ -4,6 +4,5 @@ class NoCamera : Exception()
class AlreadyStarted : Exception()
class AlreadyStopped : Exception()
class CameraError : Exception()
class TorchWhenStopped : Exception()
class ZoomWhenStopped : Exception()
class ZoomNotInRange : Exception()
\ No newline at end of file
...
...
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt
View file @
d316b6a
...
...
@@ -237,12 +237,8 @@ class MobileScannerHandler(
}
private fun toggleTorch(call: MethodCall, result: MethodChannel.Result) {
try {
mobileScanner!!.toggleTorch(call.arguments == 1)
result.success(null)
} catch (e: TorchWhenStopped) {
result.error("MobileScanner", "Called toggleTorch() while stopped!", null)
}
mobileScanner!!.toggleTorch(call.arguments == 1)
result.success(null)
}
private fun setScale(call: MethodCall, result: MethodChannel.Result) {
...
...
macos/Classes/MobileScannerPlugin.swift
View file @
d316b6a
...
...
@@ -277,7 +277,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
// Turn on the torch if requested.
if
(
torch
)
{
do
{
toggleTorchInternal
(
.
on
)
self
.
toggleTorchInternal
(
.
on
)
}
catch
{
result
(
FlutterError
(
code
:
error
.
localizedDescription
,
message
:
nil
,
details
:
nil
))
return
...
...
@@ -335,7 +335,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
let
requestedTorchMode
:
AVCaptureDevice
.
TorchMode
=
call
.
arguments
as!
Int
==
1
?
.
on
:
.
off
do
{
try
toggleTorchInternal
(
requestedTorchMode
)
try
self
.
toggleTorchInternal
(
requestedTorchMode
)
result
(
nil
)
}
catch
{
result
(
FlutterError
(
code
:
error
.
localizedDescription
,
message
:
nil
,
details
:
nil
))
...
...
Please
register
or
login
to post a comment