vision_barcode_scanner 0.0.1
vision_barcode_scanner: ^0.0.1 copied to clipboard
A Vision Based Barcode Scanner Plugin for Flutter.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:vision_barcode_scanner/vision_barcode_scanner.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String? scannedCode;
void _onBarcodeDetected(String barcode) {
setState(() {
scannedCode = barcode;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Vision Barcode Scanner')),
body: Stack(
children: [
Positioned.fill(
child: VisionBarcodeScannerView(
onBarcodeDetected: _onBarcodeDetected,
),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
color: Colors.black54,
padding: const EdgeInsets.all(16),
child: Text(
scannedCode ?? 'Scanning...',
style: const TextStyle(color: Colors.white, fontSize: 20),
),
),
),
],
),
),
);
}
}