Commit 93cae91b authored by Leon Tappe's avatar Leon Tappe 🔥
Browse files

simplify filtering qr code events

parent ab54357e
......@@ -467,20 +467,20 @@ class _HomePageState extends State<HomePage> {
void _onQRViewCreated(QRViewController controller) {
_qrController = controller;
_lastResult = '';
controller.scannedDataStream.listen((scanData) {
if ((scanData.code?.isNotEmpty ?? false) && !_disconnected) {
if (_lastResult != scanData.code) {
// check for valid base64 or else cancel
try {
final Uint8List decoded = base64.decode(scanData.code!);
if (decoded.isEmpty) return;
} catch (e) {
return;
}
_qrResult = scanData;
_lastResult = _qrResult!.code!;
_bloc!.onAdd(_lastResult);
controller.scannedDataStream
.where((scanData) => (scanData.code?.isNotEmpty ?? false) && (_lastResult != scanData.code))
.listen((scanData) {
if (!_disconnected) {
// check for valid base64 or else cancel
try {
final Uint8List decoded = base64.decode(scanData.code!);
if (decoded.isEmpty) return;
} catch (e) {
return;
}
_qrResult = scanData;
_lastResult = _qrResult!.code!;
_bloc!.onAdd(_lastResult);
}
});
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment