From b9ee0157d28e50fbd62fd3cf25f36b998f64c788 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 5 Jan 2022 12:10:44 +1100 Subject: [PATCH] Allow toggle of camera and flash when scanning barcodes --- assets/release_notes.md | 3 +++ lib/barcode.dart | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/assets/release_notes.md b/assets/release_notes.md index 8d732995..e57c1795 100644 --- a/assets/release_notes.md +++ b/assets/release_notes.md @@ -4,6 +4,9 @@ ### 0.x.x - January 2022 --- +- Enable usage of camera flash when scanning barcodes +- Enable camera toggle when scanning barcodes +- Updated icon set - Removed "upload error report" functionality (instead link to GitHub issues) - Updated multiple language translations diff --git a/lib/barcode.dart b/lib/barcode.dart index aa1b6384..a173c41f 100644 --- a/lib/barcode.dart +++ b/lib/barcode.dart @@ -461,6 +461,19 @@ class _QRViewState extends State { final BarcodeHandler _handler; + bool flash_status = false; + + Future updateFlashStatus() async { + final bool? status = await _controller?.getFlashStatus(); + + flash_status = status != null && status; + + // Reload + setState(() { + + }); + } + // In order to get hot reload to work we need to pause the camera if the platform // is android, or resume the camera if the platform is iOS. @override @@ -494,6 +507,21 @@ class _QRViewState extends State { return Scaffold( appBar: AppBar( title: Text(L10().scanBarcode), + actions: [ + IconButton( + icon: Icon(Icons.flip_camera_android), + onPressed: () { + _controller?.flipCamera(); + } + ), + IconButton( + icon: flash_status ? Icon(Icons.flash_off) : Icon(Icons.flash_on), + onPressed: () { + _controller?.toggleFlash(); + updateFlashStatus(); + }, + ) + ], ), body: Stack( children: [