From 8cc0e29e54ae14bba0fe443de64851a29d2c8a16 Mon Sep 17 00:00:00 2001 From: Khoren Markosyan Date: Thu, 16 Feb 2023 12:17:29 +0400 Subject: [PATCH] zxscanner version: 1.1.2+12 --- zxscanner/lib/pages/scanner_page.dart | 36 ++------------------------- zxscanner/pubspec.lock | 13 +++++----- zxscanner/pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 41 deletions(-) diff --git a/zxscanner/lib/pages/scanner_page.dart b/zxscanner/lib/pages/scanner_page.dart index dd69b99..3c800a2 100644 --- a/zxscanner/lib/pages/scanner_page.dart +++ b/zxscanner/lib/pages/scanner_page.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_zxing/flutter_zxing.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:image_picker/image_picker.dart'; import '../models/models.dart' as model; import '../utils/db_service.dart'; @@ -17,8 +15,6 @@ class ScannerPage extends StatefulWidget { } class _ScannerPageState extends State { - final ImagePicker _picker = ImagePicker(); - @override Widget build(BuildContext context) { return Scaffold( @@ -26,45 +22,17 @@ class _ScannerPageState extends State { title: const Text('Scanner'), ), body: ReaderWidget( + actionButtonsAlignment: Alignment.topCenter, onScan: (Code result) async { addCode(result); }, ), - floatingActionButton: FloatingActionButton( - onPressed: pickImage, - child: const Icon(FontAwesomeIcons.image), - ), ); } - // ignore: always_declare_return_types - pickImage() async { - try { - final XFile? file = await _picker.pickImage(source: ImageSource.gallery); - if (file != null) { - readCodeFromImage(file); - } - } catch (e) { - debugPrint(e.toString()); - context.showToast(e.toString()); - } - } - - Future readCodeFromImage(XFile file) async { - final Code? result = await zx.readBarcodeImagePath(file); - if (result != null && result.isValid) { - addCode(result); - } else { - if (!mounted) { - return; - } - context.showToast('No code found'); - } - } - void addCode(Code result) { final model.Code code = model.Code.fromCodeResult(result); DbService.instance.addCode(code); - context.showToast('Code added:\n${code.text ?? ''}'); + context.showToast('Barcode saved:\n${code.text ?? ''}'); } } diff --git a/zxscanner/pubspec.lock b/zxscanner/pubspec.lock index 49f55eb..2342760 100644 --- a/zxscanner/pubspec.lock +++ b/zxscanner/pubspec.lock @@ -360,10 +360,11 @@ packages: flutter_zxing: dependency: "direct main" description: - path: ".." - relative: true - source: path - version: "1.0.0" + name: flutter_zxing + sha256: "3d66e7b4f45d4402250e770a4d503765fd34b3dc9021a2d1f8bfa080422df4d9" + url: "https://pub.dev" + source: hosted + version: "1.0.1" font_awesome_flutter: dependency: "direct main" description: @@ -560,10 +561,10 @@ packages: dependency: transitive description: name: markdown - sha256: "4ed544d2ce84975b2ab5cbd4268f2d31f47858553ae2295c92fdf5d6e431a927" + sha256: b3c60dee8c2af50ad0e6e90cceba98e47718a6ee0a7a6772c77846a0cc21f78b url: "https://pub.dev" source: hosted - version: "7.0.0" + version: "7.0.1" matcher: dependency: transitive description: diff --git a/zxscanner/pubspec.yaml b/zxscanner/pubspec.yaml index 31fc401..117e0c6 100644 --- a/zxscanner/pubspec.yaml +++ b/zxscanner/pubspec.yaml @@ -2,7 +2,7 @@ name: zxscanner description: A barcode scanner application. publish_to: "none" -version: 1.1.1+11 +version: 1.1.2+12 environment: sdk: ">=2.19.0 <3.0.0"