lottis_birthday_escaperoom_app/lib/scanned_barcode_label.dart

36 lines
902 B
Dart
Raw Permalink Normal View History

2024-08-17 03:19:32 +00:00
import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
class ScannedBarcodeLabel extends StatelessWidget {
const ScannedBarcodeLabel({
super.key,
required this.barcodes,
});
final Stream<BarcodeCapture> barcodes;
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: barcodes,
builder: (context, snapshot) {
final scannedBarcodes = snapshot.data?.barcodes ?? [];
if (scannedBarcodes.isEmpty) {
return const Text(
'Scan something!',
overflow: TextOverflow.fade,
style: TextStyle(color: Colors.white),
);
}
return Text(
scannedBarcodes.first.displayValue ?? 'No display value.',
overflow: TextOverflow.fade,
style: const TextStyle(color: Colors.white),
);
},
);
}
}