Procházet zdrojové kódy

1、扫一扫支持前置摄像头

guanxinyi před 1 rokem
rodič
revize
219d308c53
1 změnil soubory, kde provedl 24 přidání a 2 odebrání
  1. 24 2
      lib/pages/widgets/qr_view_example.dart

+ 24 - 2
lib/pages/widgets/qr_view_example.dart

@@ -16,11 +16,32 @@ class _QRViewExampleState extends State<QRViewExample> {
   Barcode? result;
   QRViewController? controller;
   final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
-
+  CameraFacing _cameraFacing = CameraFacing.front;
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-      appBar: VAppBar(titleText: "扫一扫"),
+      appBar: VAppBar(
+        titleText: "扫一扫",
+        actions: [
+          // IconButton(
+          //   onPressed: () {
+          //     setState(() {
+          //       _cameraFacing = _cameraFacing == CameraFacing.back
+          //           ? CameraFacing.front
+          //           : CameraFacing.back;
+          //     });
+          //   },
+          //   icon: Icon(
+          //     Icons.change_circle_outlined,
+          //     color: Colors.white,
+          //     size: 36,
+          //   ),
+          // ),
+          // SizedBox(
+          //   width: 8,
+          // ),
+        ],
+      ),
       body: Column(
         children: <Widget>[
           Expanded(
@@ -54,6 +75,7 @@ class _QRViewExampleState extends State<QRViewExample> {
         : 300.0;
     return QRView(
       key: qrKey,
+      cameraFacing: _cameraFacing,
       onQRViewCreated: _onQRViewCreated,
       overlay: QrScannerOverlayShape(
         borderColor: Theme.of(context).colorScheme.primary,