smart_barcode_reader 0.0.1+2
smart_barcode_reader: ^0.0.1+2 copied to clipboard
A Flutter package for intelligently detecting and processing barcode scanner inputs, supporting formats like EAN-13 with adaptive speed and length validation.
import 'package:flutter/material.dart';
import 'package:smart_barcode_reader/smart_barcode_reader.dart';
void main() {
runApp(const SmartBarcodeReaderExample());
}
class SmartBarcodeReaderExample extends StatelessWidget {
const SmartBarcodeReaderExample({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Smart Barcode Reader Demo')),
body: SmartBarCodeReaderWidget(
options: SmartBarCodeReaderOptions(
onBarcodeDetected: (barcode) {
debugPrint('Scanned barcode: $barcode');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Barcode: $barcode')),
);
},
minLength: 6,
maxLength: 13,
maxInterKeyDurationMs: 30,
tolerance: 2.5,
),
child: const Center(
child: Text(
'Scan a barcode',
style: TextStyle(fontSize: 20),
),
),
),
),
);
}
}