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(),

View File

@@ -789,6 +789,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.4"
permission_handler:
dependency: transitive
description:
name: permission_handler
sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb"
url: "https://pub.dev"
source: hosted
version: "11.3.1"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: "71bbecfee799e65aff7c744761a57e817e73b738fedf62ab7afd5593da21f9f1"
url: "https://pub.dev"
source: hosted
version: "12.0.13"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0
url: "https://pub.dev"
source: hosted
version: "9.4.5"
permission_handler_html:
dependency: transitive
description:
name: permission_handler_html
sha256: "38f000e83355abb3392140f6bc3030660cfaef189e1f87824facb76300b4ff24"
url: "https://pub.dev"
source: hosted
version: "0.1.3+5"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9
url: "https://pub.dev"
source: hosted
version: "4.2.3"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
url: "https://pub.dev"
source: hosted
version: "0.2.1"
petitparser:
dependency: transitive
description:
@@ -941,6 +989,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
simple_barcode_scanner:
dependency: "direct main"
description:
name: simple_barcode_scanner
sha256: "993c4b0e22bbe6cf127f8e0001574fd54015b90e0698a058ec9fdb2fdf84bc55"
url: "https://pub.dev"
source: hosted
version: "0.2.5"
simple_gesture_detector:
dependency: transitive
description:
@@ -1306,6 +1362,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.16.3"
webview_windows:
dependency: transitive
description:
name: webview_windows
sha256: "47fcad5875a45db29dbb5c9e6709bf5c88dcc429049872701343f91ed7255730"
url: "https://pub.dev"
source: hosted
version: "0.4.0"
win32:
dependency: transitive
description:
@@ -1363,5 +1427,5 @@ packages:
source: hosted
version: "3.1.1"
sdks:
dart: ">=3.5.0 <3.7.0"
dart: ">=3.5.3 <3.7.0"
flutter: ">=3.24.0"

View File

@@ -60,7 +60,7 @@ dependencies:
flutter_swipe_detector: ^2.0.0
youtube_player_iframe: ^5.2.0
syncfusion_flutter_barcodes: ^26.2.10
# simple_barcode_scanner: ^0.2.5
simple_barcode_scanner: ^0.2.5
mobile_scanner: ^6.0.2
flutter_launcher_icons: ^0.13.1
flutter_barcode_scanner: ^2.0.0

View File

@@ -8,19 +8,25 @@
#include <firebase_core/firebase_core_plugin_c_api.h>
#include <geolocator_windows/geolocator_windows.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <printing/printing_plugin.h>
#include <syncfusion_pdfviewer_windows/syncfusion_pdfviewer_windows_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
#include <webview_windows/webview_windows_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
FirebaseCorePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
GeolocatorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("GeolocatorWindows"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
PrintingPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PrintingPlugin"));
SyncfusionPdfviewerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SyncfusionPdfviewerWindowsPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
WebviewWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("WebviewWindowsPlugin"));
}

View File

@@ -5,9 +5,11 @@
list(APPEND FLUTTER_PLUGIN_LIST
firebase_core
geolocator_windows
permission_handler_windows
printing
syncfusion_pdfviewer_windows
url_launcher_windows
webview_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST