Navaron Bracke

add new toggleTorch() method to platform interface

... ... @@ -177,8 +177,6 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
await methodChannel.invokeMethod<void>('resetScale');
}
// TODO: remove the 'torch' function from native
@override
Future<void> setZoomScale(double zoomScale) async {
await methodChannel.invokeMethod<void>('setScale', zoomScale);
... ... @@ -275,6 +273,11 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
}
@override
Future<void> toggleTorch() async {
await methodChannel.invokeMethod<void>('toggleTorch');
}
@override
Future<void> updateScanWindow(Rect? window) async {
if (_textureId == null) {
return;
... ...
... ... @@ -90,6 +90,11 @@ abstract class MobileScannerPlatform extends PlatformInterface {
throw UnimplementedError('stop() has not been implemented.');
}
/// Toggle the torch on the active camera on or off.
Future<void> toggleTorch() {
throw UnimplementedError('toggleTorch() has not been implemented.');
}
/// Update the scan window to the given [window] rectangle.
///
/// Any barcodes that do not intersect with the given [window] will be ignored.
... ...
... ... @@ -355,6 +355,14 @@ class MobileScannerWeb extends MobileScannerPlatform {
}
@override
Future<void> toggleTorch() {
throw UnsupportedError(
'Setting the torch state is not supported for video tracks on the web.\n'
'See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks',
);
}
@override
Future<void> updateScanWindow(Rect? window) {
// A scan window is not supported on the web,
// because the scanner does not expose size information for the barcodes.
... ...