Navaron Bracke

remove `setTorchState()` from the platform interface

... ... @@ -177,14 +177,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
await methodChannel.invokeMethod<void>('resetScale');
}
@override
Future<void> setTorchState(TorchState torchState) async {
if (torchState == TorchState.unavailable) {
return;
}
await methodChannel.invokeMethod<void>('torch', torchState.rawValue);
}
// TODO: remove the 'torch' function from native
@override
Future<void> setZoomScale(double zoomScale) async {
... ...
... ... @@ -374,13 +374,10 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
return;
}
final TorchState newState =
torchState == TorchState.off ? TorchState.on : TorchState.off;
// Update the torch state to the new state.
// Request the torch state to be switched to the opposite state.
// When the platform has updated the torch state,
// it will send an update through the torch state event stream.
await MobileScannerPlatform.instance.setTorchState(newState);
await MobileScannerPlatform.instance.toggleTorch();
}
/// Update the scan window with the given [window] rectangle.
... ...
... ... @@ -67,11 +67,6 @@ abstract class MobileScannerPlatform extends PlatformInterface {
/// This is only supported on the web.
void setBarcodeLibraryScriptUrl(String scriptUrl) {}
/// Set the torch state of the active camera.
Future<void> setTorchState(TorchState torchState) {
throw UnimplementedError('setTorchState() has not been implemented.');
}
/// Set the zoom scale of the camera.
///
/// The [zoomScale] must be between `0.0` and `1.0` (both inclusive).
... ...
... ... @@ -236,14 +236,6 @@ class MobileScannerWeb extends MobileScannerPlatform {
}
@override
Future<void> setTorchState(TorchState torchState) {
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> setZoomScale(double zoomScale) {
throw UnsupportedError(
'Setting the zoom scale is not supported for video tracks on the web.\n'
... ...