Navaron Bracke

remove `setTorchState()` from the platform interface

@@ -177,14 +177,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform { @@ -177,14 +177,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
177 await methodChannel.invokeMethod<void>('resetScale'); 177 await methodChannel.invokeMethod<void>('resetScale');
178 } 178 }
179 179
180 - @override  
181 - Future<void> setTorchState(TorchState torchState) async {  
182 - if (torchState == TorchState.unavailable) {  
183 - return;  
184 - }  
185 -  
186 - await methodChannel.invokeMethod<void>('torch', torchState.rawValue);  
187 - } 180 + // TODO: remove the 'torch' function from native
188 181
189 @override 182 @override
190 Future<void> setZoomScale(double zoomScale) async { 183 Future<void> setZoomScale(double zoomScale) async {
@@ -374,13 +374,10 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { @@ -374,13 +374,10 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> {
374 return; 374 return;
375 } 375 }
376 376
377 - final TorchState newState =  
378 - torchState == TorchState.off ? TorchState.on : TorchState.off;  
379 -  
380 - // Update the torch state to the new state. 377 + // Request the torch state to be switched to the opposite state.
381 // When the platform has updated the torch state, 378 // When the platform has updated the torch state,
382 // it will send an update through the torch state event stream. 379 // it will send an update through the torch state event stream.
383 - await MobileScannerPlatform.instance.setTorchState(newState); 380 + await MobileScannerPlatform.instance.toggleTorch();
384 } 381 }
385 382
386 /// Update the scan window with the given [window] rectangle. 383 /// Update the scan window with the given [window] rectangle.
@@ -67,11 +67,6 @@ abstract class MobileScannerPlatform extends PlatformInterface { @@ -67,11 +67,6 @@ abstract class MobileScannerPlatform extends PlatformInterface {
67 /// This is only supported on the web. 67 /// This is only supported on the web.
68 void setBarcodeLibraryScriptUrl(String scriptUrl) {} 68 void setBarcodeLibraryScriptUrl(String scriptUrl) {}
69 69
70 - /// Set the torch state of the active camera.  
71 - Future<void> setTorchState(TorchState torchState) {  
72 - throw UnimplementedError('setTorchState() has not been implemented.');  
73 - }  
74 -  
75 /// Set the zoom scale of the camera. 70 /// Set the zoom scale of the camera.
76 /// 71 ///
77 /// The [zoomScale] must be between `0.0` and `1.0` (both inclusive). 72 /// The [zoomScale] must be between `0.0` and `1.0` (both inclusive).
@@ -236,14 +236,6 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -236,14 +236,6 @@ class MobileScannerWeb extends MobileScannerPlatform {
236 } 236 }
237 237
238 @override 238 @override
239 - Future<void> setTorchState(TorchState torchState) {  
240 - throw UnsupportedError(  
241 - 'Setting the torch state is not supported for video tracks on the web.\n'  
242 - 'See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks',  
243 - );  
244 - }  
245 -  
246 - @override  
247 Future<void> setZoomScale(double zoomScale) { 239 Future<void> setZoomScale(double zoomScale) {
248 throw UnsupportedError( 240 throw UnsupportedError(
249 'Setting the zoom scale is not supported for video tracks on the web.\n' 241 'Setting the zoom scale is not supported for video tracks on the web.\n'