File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// ignore: avoid_web_libraries_in_flutter
22import 'dart:html' as html;
33import 'dart:ui' as ui;
4+ import 'dart:js' as js;
45
56import 'package:flutter/material.dart' ;
67import '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 ) {
You can’t perform that action at this time.
0 commit comments