Julian Steenbakker

feat: add hasTorch function

... ... @@ -19,6 +19,7 @@ Improvements:
Features:
* Added a new `placeholderBuilder` function to the `MobileScanner` widget to customize the preview placeholder.
* Added `autoStart` parameter to MobileScannerController(). If set to false, controller won't start automatically.
* Added `hasTorch` function on MobileScannerController(). After starting the controller, you can check if the device has a torch.
Fixed:
* Fixed a memory leak where the `MobileScanner` widget would never close its subscription to the barcode events.
... ...
... ... @@ -101,6 +101,19 @@ class MobileScannerController {
bool? _hasTorch;
/// Returns whether the device has a torch.
///
/// Throws an error if the controller is not initialized.
bool get hasTorch {
if (_hasTorch == null) {
throw const MobileScannerException(
errorCode: MobileScannerErrorCode.controllerUninitialized,
);
}
return _hasTorch!;
}
/// Set the starting arguments for the camera
Map<String, dynamic> _argumentsToMap({CameraFacing? cameraFacingOverride}) {
final Map<String, dynamic> arguments = {};
... ...