Skip to content

Commit 20dba6c

Browse files
authored
Set qrBox width and height
1 parent c7a5f2f commit 20dba6c

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

lib/screens/web.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ignore: avoid_web_libraries_in_flutter
22
import 'dart:html' as html;
33
import 'dart:ui' as ui;
4+
import 'dart:js' as js;
45

56
import 'package:flutter/material.dart';
67
import 'package:simple_barcode_scanner/constant.dart';
@@ -15,6 +16,8 @@ class BarcodeScanner extends StatelessWidget {
1516
final Function(String) onScanned;
1617
final String? appBarTitle;
1718
final bool? centerTitle;
19+
final int scanWidth;
20+
final int scanHeight;
1821

1922
const BarcodeScanner({
2023
Key? key,
@@ -25,6 +28,8 @@ class BarcodeScanner extends StatelessWidget {
2528
required this.onScanned,
2629
this.appBarTitle,
2730
this.centerTitle,
31+
this.scanWidth = 288,
32+
this.scanHeight = 120
2833
}) : super(key: key);
2934

3035
@override
@@ -36,8 +41,15 @@ class BarcodeScanner extends StatelessWidget {
3641
..src = PackageConstant.barcodeFileWebPath
3742
..style.border = 'none'
3843
..onLoad.listen((event) async {
39-
/// Barcode listener on success barcode scanned
4044
html.window.onMessage.listen((event) {
45+
/// Create reader setting qrBox width and height
46+
html.CustomEvent event = new html.CustomEvent("reader", detail : {
47+
"qrBoxWidth": scanWidth,
48+
"qrBoxHeight": scanHeight
49+
});
50+
html.window.document.dispatchEvent(event);
51+
52+
/// Barcode listener on success barcode scanned
4153
/// If barcode is null then assign scanned barcode
4254
/// and close the screen otherwise keep scanning
4355
if (barcodeNumber == null) {

0 commit comments

Comments
 (0)