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-11-17 11:20:52 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4cbdce8e74d38b20d3420aaa90995d8eebcbe360
4cbdce8e
1 parent
5b60e607
remove the obsolete jsQr implementation
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
104 deletions
lib/src/web/jsqr.dart
lib/src/web/jsqr.dart
deleted
100644 → 0
View file @
5b60e60
@JS
()
library
jsqr
;
import
'dart:async'
;
import
'dart:html'
;
import
'dart:typed_data'
;
import
'package:js/js.dart'
;
import
'package:mobile_scanner/src/enums/barcode_format.dart'
;
import
'package:mobile_scanner/src/enums/camera_facing.dart'
;
import
'package:mobile_scanner/src/objects/barcode.dart'
;
import
'package:mobile_scanner/src/web/base.dart'
;
@JS
(
'jsQR'
)
external
Code
?
jsQR
(
dynamic
data
,
int
?
width
,
int
?
height
);
@JS
()
class
Code
{
external
String
get
data
;
external
Uint8ClampedList
get
binaryData
;
}
/// Barcode reader that uses jsQR library.
/// jsQR supports only QR codes format.
class
JsQrCodeReader
extends
WebBarcodeReaderBase
with
InternalStreamCreation
,
InternalTorchDetection
{
JsQrCodeReader
({
required
super
.
videoContainer
});
@override
bool
get
isStarted
=>
localMediaStream
!=
null
;
@override
Future
<
void
>
start
({
required
CameraFacing
cameraFacing
,
List
<
BarcodeFormat
>?
formats
,
Duration
?
detectionTimeout
,
})
async
{
videoContainer
.
children
=
[
video
];
if
(
detectionTimeout
!=
null
)
{
frameInterval
=
detectionTimeout
;
}
final
stream
=
await
initMediaStream
(
cameraFacing
);
prepareVideoElement
(
video
);
if
(
stream
!=
null
)
{
await
attachStreamToVideo
(
stream
,
video
);
}
}
@override
void
prepareVideoElement
(
VideoElement
videoSource
)
{
// required to tell iOS safari we don't want fullscreen
videoSource
.
setAttribute
(
'playsinline'
,
'true'
);
}
@override
Future
<
void
>
attachStreamToVideo
(
MediaStream
stream
,
VideoElement
videoSource
,
)
async
{
localMediaStream
=
stream
;
videoSource
.
srcObject
=
stream
;
await
videoSource
.
play
();
}
@override
Stream
<
Barcode
?>
detectBarcodeContinuously
()
async
*
{
yield
*
Stream
.
periodic
(
frameInterval
,
(
_
)
{
return
_captureFrame
(
video
);
}).
asyncMap
((
event
)
async
{
final
code
=
await
event
;
if
(
code
==
null
)
{
return
null
;
}
return
Barcode
(
rawValue:
code
.
data
,
rawBytes:
Uint8List
.
fromList
(
code
.
binaryData
),
format:
BarcodeFormat
.
qrCode
,
);
});
}
@override
Future
<
void
>
stopDetectBarcodeContinuously
()
async
{
return
;
}
/// Captures a frame and analyzes it for QR codes
Future
<
Code
?>
_captureFrame
(
VideoElement
video
)
async
{
if
(
localMediaStream
==
null
)
return
null
;
final
canvas
=
CanvasElement
(
width:
video
.
videoWidth
,
height:
video
.
videoHeight
);
final
ctx
=
canvas
.
context2D
;
ctx
.
drawImage
(
video
,
0
,
0
);
final
imgData
=
ctx
.
getImageData
(
0
,
0
,
canvas
.
width
!,
canvas
.
height
!);
final
code
=
jsQR
(
imgData
.
data
,
canvas
.
width
,
canvas
.
height
);
return
code
;
}
}
Please
register
or
login
to post a comment