lottis_birthday_escaperoom_app/lib/scanned_barcode_label.dart
2024-08-17 05:19:32 +02:00

36 lines
902 B
Dart

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),
);
},
);
}
}