Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
933 B

import 'package:flutter/material.dart';
import 'package:flutter_zxing/flutter_zxing.dart';
2 years ago
import '../models/models.dart' as model;
import '../utils/db_service.dart';
import '../utils/extensions.dart';
class ScannerPage extends StatefulWidget {
const ScannerPage({
super.key,
});
@override
State<ScannerPage> createState() => _ScannerPageState();
}
class _ScannerPageState extends State<ScannerPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Scanner'),
),
3 years ago
body: ReaderWidget(
actionButtonsAlignment: Alignment.topCenter,
2 years ago
onScan: (Code result) async {
addCode(result);
},
),
);
}
2 years ago
void addCode(Code result) {
final model.Code code = model.Code.fromCodeResult(result);
DbService.instance.addCode(code);
context.showToast('Barcode saved:\n${code.text ?? ''}');
}
}