Browse Source

zxscanner version: 1.1.2+12

pull/89/head
Khoren Markosyan 2 years ago
parent
commit
8cc0e29e54
  1. 36
      zxscanner/lib/pages/scanner_page.dart
  2. 13
      zxscanner/pubspec.lock
  3. 2
      zxscanner/pubspec.yaml

36
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<ScannerPage> {
final ImagePicker _picker = ImagePicker();
@override
Widget build(BuildContext context) {
return Scaffold(
@ -26,45 +22,17 @@ class _ScannerPageState extends State<ScannerPage> {
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<void> 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 ?? ''}');
}
}

13
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:

2
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"

Loading…
Cancel
Save