Navaron Bracke

do not throw when calling stop if already stopped

... ... @@ -208,7 +208,7 @@ class MobileScannerPlugin : FlutterPlugin, ActivityAware, MethodChannel.MethodCa
handler!!.stop()
result.success(null)
} catch (e: AlreadyStopped) {
result.error("MobileScanner", "Called stop() while already stopped!", null)
result.success(null)
}
}
... ...
... ... @@ -107,11 +107,7 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin {
private func stop(_ result: @escaping FlutterResult) {
do {
try mobileScanner.stop()
} catch {
result(FlutterError(code: "MobileScanner",
message: "Called stop() while already stopped!",
details: nil))
}
} catch {}
result(nil)
}
... ...
... ... @@ -260,9 +260,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
func stop(_ result: FlutterResult) {
if (device == nil) {
result(FlutterError(code: "MobileScanner",
message: "Called stop() while already stopped!",
details: nil))
result(nil)
return
}
captureSession.stopRunning()
... ...