yubioath-flutter/lib/android/qr_scanner/qr_scanner_view.dart
2022-03-28 11:08:26 +02:00

31 lines
958 B
Dart
Executable File

import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import '../../app/navigation_service.dart';
class QrScannerView extends StatelessWidget {
const QrScannerView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(0),
child: Stack(children: [
MobileScanner(
controller: MobileScannerController(
facing: CameraFacing.back, torchEnabled: false),
onDetect: (barcode, args) {
final String? code = barcode.rawValue;
BuildContext dialogContext =
NavigationService.navigatorKey.currentContext!;
if (Navigator.of(dialogContext).canPop()) {
// prevent several callbacks
Navigator.of(dialogContext).pop(code);
}
}),
]),
));
}
}