From 74946d005c8e24d4231aab9af59b711d3671b878 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Mon, 20 Feb 2023 16:23:49 +0100 Subject: [PATCH] added barcode scanner --- android/app/build.gradle | 4 +- lib/pages/scanner_page.dart | 10 ++++- web/index.html | 78 +++++++++++++++++++------------------ 3 files changed, 52 insertions(+), 40 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index d8c9ecd..4fef84e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion flutter.compileSdkVersion + compileSdkVersion 33 ndkVersion flutter.ndkVersion compileOptions { @@ -47,7 +47,7 @@ android { applicationId "com.example.smoke_cess_app" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. - minSdkVersion flutter.minSdkVersion + minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/lib/pages/scanner_page.dart b/lib/pages/scanner_page.dart index 5ebb699..fc4abe0 100644 --- a/lib/pages/scanner_page.dart +++ b/lib/pages/scanner_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:mobile_scanner/mobile_scanner.dart'; import 'package:smoke_cess_app/service/settings_service.dart'; class ScannerPage extends StatelessWidget { @@ -10,7 +11,14 @@ class ScannerPage extends StatelessWidget { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text('Hier taucht die Kamera zum Scannen auf'), + Expanded(child: MobileScanner(fit: BoxFit.contain,onDetect: (capture) { + final List barcodes = capture.barcodes; + for (final barcode in barcodes) { + debugPrint('Barcode found! ${barcode.rawValue}'); + } }, + + )) + , const SizedBox(height: 30), ElevatedButton( style: ElevatedButton.styleFrom( diff --git a/web/index.html b/web/index.html index 277f035..366d37f 100644 --- a/web/index.html +++ b/web/index.html @@ -1,7 +1,7 @@ - - - + - - - + + + - - - - - + + + + + - - + + - smoke_cess_app - + smoke_cess_app + - - - - - - + + + + + - + + +