add scanner back

This commit is contained in:
2024-11-26 23:30:36 +02:00
parent 9daa6c0020
commit a6d645f1d7
5 changed files with 116 additions and 42 deletions

View File

@@ -14,6 +14,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
class LoyaltyCards extends StatefulWidget {
final AppUser signedInUser;
@@ -142,48 +143,49 @@ class _LoyaltyCardsState extends State<LoyaltyCards> {
),
const SizedBox(width: 10),
MIHButton(
onTap: () async {
String bcodeScanResults;
try {
bcodeScanResults = await FlutterBarcodeScanner.scanBarcode(
'#ff6666',
'Cancel',
true,
ScanMode.BARCODE,
);
} on PlatformException {
bcodeScanResults = "Platform not supported";
}
onTap:
// () async {
// String bcodeScanResults;
// try {
// bcodeScanResults = await FlutterBarcodeScanner.scanBarcode(
// '#ff6666',
// 'Cancel',
// true,
// ScanMode.BARCODE,
// );
// } on PlatformException {
// bcodeScanResults = "Platform not supported";
// }
if (!mounted) return;
setState(() {
cardNumberController.text = bcodeScanResults;
});
// if (!mounted) return;
// setState(() {
// cardNumberController.text = bcodeScanResults;
// });
// },
// () {
// openscanner();
// },
() async {
print("here");
String? res = await SimpleBarcodeScanner.scanBarcode(
context,
barcodeAppBar: const BarcodeAppBar(
appBarTitle: 'Scan Bardcode',
centerTitle: true,
enableBackButton: true,
backButtonIcon: Icon(Icons.arrow_back),
),
isShowFlashIcon: true,
delayMillis: 500,
cameraFace: CameraFace.back,
scanFormat: ScanFormat.ONLY_BARCODE,
);
if (res != null) {
setState(() {
cardNumberController.text = res;
});
}
},
// () {
// openscanner();
// },
// () async {
// print("here");
// String? res = await SimpleBarcodeScanner.scanBarcode(
// context,
// barcodeAppBar: const BarcodeAppBar(
// appBarTitle: 'Scan Bardcode',
// centerTitle: true,
// enableBackButton: true,
// backButtonIcon: Icon(Icons.arrow_back),
// ),
// isShowFlashIcon: true,
// delayMillis: 500,
// cameraFace: CameraFace.back,
// scanFormat: ScanFormat.ONLY_BARCODE,
// );
// if (res != null) {
// setState(() {
// cardNumberController.text = res;
// });
// }
// },
buttonText: "Scan",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),