Skip to content

Commit 37a5c01

Browse files
committed
version updated
1 parent 1f992ec commit 37a5c01

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","native_build":true,"dependencies":[]}],"android":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","dependencies":[]}]},"dependencyGraph":[{"name":"mobile_scanner","dependencies":[]}],"date_created":"2022-11-15 19:46:34.516555","version":"3.3.8"}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","native_build":true,"dependencies":[]}],"android":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dartlang.org/mobile_scanner-2.0.0/","dependencies":[]}]},"dependencyGraph":[{"name":"mobile_scanner","dependencies":[]}],"date_created":"2022-11-15 21:44:22.534748","version":"3.3.8"}

example/lib/main.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,10 @@ class _MyHomePageState extends State<MyHomePage> {
4545
// validateText: 'https://', // link to be validated
4646
// validateType: ValidateType.startsWith,
4747
onScan: (String value) {
48-
// debugPrint(value);
49-
// setState(() {
50-
// barcode = value;
51-
// });
52-
},
53-
canPop: false,
54-
onDetect: ( barcode, args) {
55-
debugPrint(barcode.barcodes.first.rawValue!);
48+
debugPrint(value);
49+
setState(() {
50+
barcode = value;
51+
});
5652
},
5753
),
5854
),

lib/src/ai_barcode_scanner.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ class AiBarcodeScanner extends StatefulWidget {
1414
///
1515
/// [barcode] The barcode object with all information about the scanned code.
1616
/// [args] Information about the state of the MobileScanner widget
17-
final Function(BarcodeCapture barcode, MobileScannerArguments? args)?
18-
onDetect;
17+
final Function(Barcode barcode, MobileScannerArguments? args)? onDetect;
1918

2019
/// Validate barcode text with [ValidateType]
2120
/// [validateText] and [validateType] must be set together.
@@ -117,10 +116,10 @@ class AiBarcodeScanner extends StatefulWidget {
117116
this.controller,
118117
this.onDetect,
119118
this.borderColor = Colors.white,
120-
this.borderWidth = 8,
119+
this.borderWidth = 10,
121120
this.overlayColor = const Color.fromRGBO(0, 0, 0, 80),
122-
this.borderRadius = 8,
123-
this.borderLength = 36,
121+
this.borderRadius = 10,
122+
this.borderLength = 40,
124123
this.cutOutSize = 300,
125124
this.cutOutWidth,
126125
this.cutOutHeight,
@@ -180,17 +179,17 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
180179
key: widget.key,
181180
onDetect: (barcode, args) {
182181
widget.onDetect?.call(barcode, args);
183-
if (barcode.barcodes.isEmpty) {
182+
if (barcode.rawValue?.isEmpty ?? true) {
184183
debugPrint('Failed to scan Barcode');
185184
return;
186185
}
187186
if (widget.validateText?.isNotEmpty ?? false) {
188187
if (!widget.validateType!.toValidateTypeBool(
189-
barcode.barcodes.first.rawValue!, widget.validateText!)) {
188+
barcode.rawValue!, widget.validateText!)) {
190189
if (!widget.allowDuplicates) {
191190
HapticFeedback.vibrate();
192191
}
193-
final String code = barcode.barcodes.first.rawValue!;
192+
final String code = barcode.rawValue!;
194193
debugPrint('Invalid Barcode => $code');
195194
_isSuccess = false;
196195
setState(() {});
@@ -201,8 +200,8 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
201200
if (!widget.allowDuplicates) {
202201
HapticFeedback.mediumImpact();
203202
}
204-
final String code = barcode.barcodes.first.rawValue!;
205-
debugPrint('Barcode found => $code');
203+
final String code = barcode.rawValue!;
204+
debugPrint('Barcode rawValue => $code');
206205
widget.onScan(code);
207206
setState(() {});
208207
if (widget.canPop && mounted) {
@@ -265,9 +264,7 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
265264
),
266265
trailing: IconButton(
267266
tooltip: "Torch",
268-
onPressed: controller.torchEnabled
269-
? () => controller.toggleTorch()
270-
: null,
267+
onPressed: () => controller.toggleTorch(),
271268
icon: ValueListenableBuilder<TorchState>(
272269
valueListenable: controller.torchState,
273270
builder: (context, state, child) {

0 commit comments

Comments
 (0)