@@ -19,7 +19,7 @@ class AiBarcodeScanner extends StatefulWidget {
1919
2020 /// Validate barcode text with [ValidateType]
2121 /// [validateText] and [validateType] must be set together.
22- final String validateText;
22+ final String ? validateText;
2323
2424 /// Validate type [ValidateType]
2525 /// Validator working with single string value only.
@@ -138,7 +138,7 @@ class AiBarcodeScanner extends StatefulWidget {
138138 const AiBarcodeScanner ({
139139 Key ? key,
140140 required this .onScan,
141- this .validateText = '' ,
141+ this .validateText,
142142 this .validateType,
143143 this .allowDuplicates = false ,
144144 this .fit = BoxFit .cover,
@@ -172,7 +172,7 @@ class AiBarcodeScanner extends StatefulWidget {
172172 this .scanWindow,
173173 this .startDelay,
174174 this .hintWidget,
175- }) : assert (validateType != null ),
175+ }) : assert (validateText == null || validateType != null ),
176176 assert (validateText != null || validateType == null ),
177177 super (key: key);
178178
@@ -247,10 +247,11 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
247247 debugPrint ('Failed to scan Barcode' );
248248 return ;
249249 }
250- if (widget.validateText.isNotEmpty) {
250+ if (widget.validateText? .isNotEmpty == true ) {
251251 if (! widget.validateType! .toValidateTypeBool (
252- barcode.barcodes.first.rawValue ?? "" ,
253- widget.validateText)) {
252+ barcode.barcodes.first.rawValue ?? "" ,
253+ widget.validateText! ,
254+ )) {
254255 HapticFeedback .heavyImpact ();
255256 final String code = barcode.barcodes.first.rawValue! ;
256257 debugPrint ('Invalid Barcode => $code ' );
0 commit comments