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
2024-09-28 10:38:11 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
eda540fd46a008ed03079d2a4d593122bc729c3f
eda540fd
1 parent
3ec0dc12
forward barcode error events as FlutterError()'s on iOS & MacOS
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
12 deletions
ios/Classes/BarcodeHandler.swift
ios/Classes/MobileScannerPlugin.swift
macos/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift
ios/Classes/BarcodeHandler.swift
View file @
eda540f
...
...
@@ -19,6 +19,12 @@ public class BarcodeHandler: NSObject, FlutterStreamHandler {
eventChannel
.
setStreamHandler
(
self
)
}
func
publishError
(
_
error
:
FlutterError
)
{
DispatchQueue
.
main
.
async
{
self
.
eventSink
?(
error
)
}
}
func
publishEvent
(
_
event
:
[
String
:
Any
?])
{
DispatchQueue
.
main
.
async
{
self
.
eventSink
?(
event
)
...
...
ios/Classes/MobileScannerPlugin.swift
View file @
eda540f
...
...
@@ -42,10 +42,10 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
init
(
barcodeHandler
:
BarcodeHandler
,
registry
:
FlutterTextureRegistry
)
{
self
.
mobileScanner
=
MobileScanner
(
registry
:
registry
,
mobileScannerCallback
:
{
barcodes
,
error
,
image
in
if
error
!=
nil
{
barcodeHandler
.
publishEvent
([
"name"
:
MobileScannerErrorCodes
.
BARCODE_ERROR
,
"data"
:
error
!.
localizedDescription
,
])
barcodeHandler
.
publishError
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
BARCODE_ERROR
,
message
:
error
?
.
localizedDescription
,
details
:
nil
))
return
}
...
...
macos/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift
View file @
eda540f
...
...
@@ -131,10 +131,9 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
if
error
!=
nil
{
DispatchQueue
.
main
.
async
{
self
?
.
sink
?([
"name"
:
MobileScannerErrorCodes
.
BARCODE_ERROR
,
"data"
:
error
?
.
localizedDescription
,
])
self
?
.
sink
?(
FlutterError
(
code
:
MobileScannerErrorCodes
.
BARCODE_ERROR
,
message
:
error
?
.
localizedDescription
,
details
:
nil
))
}
return
}
...
...
@@ -185,10 +184,9 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
try
imageRequestHandler
.
perform
([
barcodeRequest
])
}
catch
let
error
{
DispatchQueue
.
main
.
async
{
self
?
.
sink
?([
"name"
:
MobileScannerErrorCodes
.
BARCODE_ERROR
,
"data"
:
error
.
localizedDescription
,
])
self
?
.
sink
?(
FlutterError
(
code
:
MobileScannerErrorCodes
.
BARCODE_ERROR
,
message
:
error
.
localizedDescription
,
details
:
nil
))
}
}
}
...
...
Please
register
or
login
to post a comment