Navaron Bracke
Committed by GitHub

Merge pull request #811 from navaronbracke/ios_macos_cleanup

feat: Cleanup iOS & MacOS setup
@@ -367,7 +367,7 @@ @@ -367,7 +367,7 @@
367 "$(inherited)", 367 "$(inherited)",
368 "@executable_path/Frameworks", 368 "@executable_path/Frameworks",
369 ); 369 );
370 - PRODUCT_BUNDLE_IDENTIFIER = dev.steenbakker.mobileScannerExample; 370 + PRODUCT_BUNDLE_IDENTIFIER = "com.example.mobile-scanner";
371 PRODUCT_NAME = "$(TARGET_NAME)"; 371 PRODUCT_NAME = "$(TARGET_NAME)";
372 PROVISIONING_PROFILE_SPECIFIER = ""; 372 PROVISIONING_PROFILE_SPECIFIER = "";
373 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 373 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -499,7 +499,7 @@ @@ -499,7 +499,7 @@
499 "$(inherited)", 499 "$(inherited)",
500 "@executable_path/Frameworks", 500 "@executable_path/Frameworks",
501 ); 501 );
502 - PRODUCT_BUNDLE_IDENTIFIER = dev.steenbakker.mobileScannerExample; 502 + PRODUCT_BUNDLE_IDENTIFIER = "com.example.mobile-scanner";
503 PRODUCT_NAME = "$(TARGET_NAME)"; 503 PRODUCT_NAME = "$(TARGET_NAME)";
504 PROVISIONING_PROFILE_SPECIFIER = ""; 504 PROVISIONING_PROFILE_SPECIFIER = "";
505 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 505 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -525,7 +525,7 @@ @@ -525,7 +525,7 @@
525 "$(inherited)", 525 "$(inherited)",
526 "@executable_path/Frameworks", 526 "@executable_path/Frameworks",
527 ); 527 );
528 - PRODUCT_BUNDLE_IDENTIFIER = dev.steenbakker.mobileScannerExample; 528 + PRODUCT_BUNDLE_IDENTIFIER = "com.example.mobile-scanner";
529 PRODUCT_NAME = "$(TARGET_NAME)"; 529 PRODUCT_NAME = "$(TARGET_NAME)";
530 PROVISIONING_PROFILE_SPECIFIER = ""; 530 PROVISIONING_PROFILE_SPECIFIER = "";
531 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 531 SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -27,9 +27,9 @@ @@ -27,9 +27,9 @@
27 <key>LSRequiresIPhoneOS</key> 27 <key>LSRequiresIPhoneOS</key>
28 <true/> 28 <true/>
29 <key>NSCameraUsageDescription</key> 29 <key>NSCameraUsageDescription</key>
30 - <string>We use the camera to scan barcodes</string> 30 + <string>This app needs camera access to scan QR codes</string>
31 <key>NSPhotoLibraryUsageDescription</key> 31 <key>NSPhotoLibraryUsageDescription</key>
32 - <string>We need access in order to open photos of barcodes</string> 32 + <string>This app needs photos access to get QR code from photo library</string>
33 <key>UIApplicationSupportsIndirectInputEvents</key> 33 <key>UIApplicationSupportsIndirectInputEvents</key>
34 <true/> 34 <true/>
35 <key>UILaunchStoryboardName</key> 35 <key>UILaunchStoryboardName</key>
@@ -51,10 +51,5 @@ @@ -51,10 +51,5 @@
51 </array> 51 </array>
52 <key>UIViewControllerBasedStatusBarAppearance</key> 52 <key>UIViewControllerBasedStatusBarAppearance</key>
53 <false/> 53 <false/>
54 - <key>NSCameraUsageDescription</key>  
55 - <string>This app needs camera access to scan QR codes</string>  
56 -  
57 - <key>NSPhotoLibraryUsageDescription</key>  
58 - <string>This app needs photos access to get QR code from photo library</string>  
59 </dict> 54 </dict>
60 </plist> 55 </plist>
1 name: mobile_scanner_example 1 name: mobile_scanner_example
2 description: Demonstrates how to use the mobile_scanner plugin. 2 description: Demonstrates how to use the mobile_scanner plugin.
3 publish_to: 'none' # Remove this line if you wish to publish to pub.dev 3 publish_to: 'none' # Remove this line if you wish to publish to pub.dev
  4 +version: 0.0.1
4 5
5 environment: 6 environment:
6 sdk: ">=2.12.0 <4.0.0" 7 sdk: ">=2.12.0 <4.0.0"
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 // Created by Julian Steenbakker on 24/08/2022. 5 // Created by Julian Steenbakker on 24/08/2022.
6 // 6 //
7 7
  8 +import Flutter
8 import Foundation 9 import Foundation
9 10
10 public class BarcodeHandler: NSObject, FlutterStreamHandler { 11 public class BarcodeHandler: NSObject, FlutterStreamHandler {
1 // 1 //
2 -// SwiftMobileScanner.swift 2 +// MobileScanner.swift
3 // mobile_scanner 3 // mobile_scanner
4 // 4 //
5 // Created by Julian Steenbakker on 15/02/2022. 5 // Created by Julian Steenbakker on 15/02/2022.
6 // 6 //
7 7
8 import Foundation 8 import Foundation
9 - 9 +import Flutter
10 import AVFoundation 10 import AVFoundation
11 import MLKitVision 11 import MLKitVision
12 import MLKitBarcodeScanning 12 import MLKitBarcodeScanning
@@ -191,7 +191,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega @@ -191,7 +191,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
191 throw MobileScannerError.cameraError(error) 191 throw MobileScannerError.cameraError(error)
192 } 192 }
193 193
194 - captureSession.sessionPreset = AVCaptureSession.Preset.photo; 194 + captureSession.sessionPreset = AVCaptureSession.Preset.photo
195 // Add video output. 195 // Add video output.
196 let videoOutput = AVCaptureVideoDataOutput() 196 let videoOutput = AVCaptureVideoDataOutput()
197 197
@@ -294,7 +294,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega @@ -294,7 +294,7 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
294 public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { 294 public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
295 switch keyPath { 295 switch keyPath {
296 case "torchMode": 296 case "torchMode":
297 - // off = 0; on = 1; auto = 2; 297 + // off = 0; on = 1; auto = 2
298 let state = change?[.newKey] as? Int 298 let state = change?[.newKey] as? Int
299 torchModeChangeCallback(state) 299 torchModeChangeCallback(state)
300 case "videoZoomFactor": 300 case "videoZoomFactor":
@@ -348,7 +348,6 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega @@ -348,7 +348,6 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
348 } 348 }
349 } 349 }
350 350
351 -  
352 /// Analyze a single image 351 /// Analyze a single image
353 func analyzeImage(image: UIImage, position: AVCaptureDevice.Position, callback: @escaping BarcodeScanningCallback) { 352 func analyzeImage(image: UIImage, position: AVCaptureDevice.Position, callback: @escaping BarcodeScanningCallback) {
354 let image = VisionImage(image: image) 353 let image = VisionImage(image: image)
@@ -363,18 +362,16 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega @@ -363,18 +362,16 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
363 362
364 var barcodesString: Array<String?>? 363 var barcodesString: Array<String?>?
365 364
366 -  
367 -  
368 -// /// Convert image buffer to jpeg  
369 -// private func ciImageToJpeg(ciImage: CIImage) -> Data {  
370 -//  
371 -// // let ciImage = CIImage(cvPixelBuffer: latestBuffer)  
372 -// let context:CIContext = CIContext.init(options: nil)  
373 -// let cgImage:CGImage = context.createCGImage(ciImage, from: ciImage.extent)!  
374 -// let uiImage:UIImage = UIImage(cgImage: cgImage, scale: 1, orientation: UIImage.Orientation.up)  
375 -//  
376 -// return uiImage.jpegData(compressionQuality: 0.8)!;  
377 -// } 365 + // /// Convert image buffer to jpeg
  366 + // private func ciImageToJpeg(ciImage: CIImage) -> Data {
  367 + //
  368 + // // let ciImage = CIImage(cvPixelBuffer: latestBuffer)
  369 + // let context:CIContext = CIContext.init(options: nil)
  370 + // let cgImage:CGImage = context.createCGImage(ciImage, from: ciImage.extent)!
  371 + // let uiImage:UIImage = UIImage(cgImage: cgImage, scale: 1, orientation: UIImage.Orientation.up)
  372 + //
  373 + // return uiImage.jpegData(compressionQuality: 0.8)!
  374 + // }
378 375
379 /// Rotates images accordingly 376 /// Rotates images accordingly
380 func imageOrientation( 377 func imageOrientation(
1 -#import <Flutter/Flutter.h>  
2 -  
3 -@interface MobileScannerPlugin : NSObject<FlutterPlugin>  
4 -@end  
1 -#import "MobileScannerPlugin.h"  
2 -#if __has_include(<mobile_scanner/mobile_scanner-Swift.h>)  
3 -#import <mobile_scanner/mobile_scanner-Swift.h>  
4 -#else  
5 -// Support project import fallback if the generated compatibility header  
6 -// is not copied when this plugin is created as a library.  
7 -// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816  
8 -#import "mobile_scanner-Swift.h"  
9 -#endif  
10 -  
11 -@implementation MobileScannerPlugin  
12 -+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {  
13 - [SwiftMobileScannerPlugin registerWithRegistrar:registrar];  
14 -}  
15 -@end  
@@ -4,7 +4,7 @@ import MLKitBarcodeScanning @@ -4,7 +4,7 @@ import MLKitBarcodeScanning
4 import AVFoundation 4 import AVFoundation
5 import UIKit 5 import UIKit
6 6
7 -public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin { 7 +public class MobileScannerPlugin: NSObject, FlutterPlugin {
8 8
9 /// The mobile scanner object that handles all logic 9 /// The mobile scanner object that handles all logic
10 private let mobileScanner: MobileScanner 10 private let mobileScanner: MobileScanner
@@ -16,7 +16,7 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin { @@ -16,7 +16,7 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin {
16 static var scanWindow: [CGFloat]? 16 static var scanWindow: [CGFloat]?
17 17
18 private static func isBarcodeInScanWindow(barcode: Barcode, imageSize: CGSize) -> Bool { 18 private static func isBarcodeInScanWindow(barcode: Barcode, imageSize: CGSize) -> Bool {
19 - let scanwindow = SwiftMobileScannerPlugin.scanWindow! 19 + let scanwindow = MobileScannerPlugin.scanWindow!
20 let barcodeminX = barcode.cornerPoints![0].cgPointValue.x 20 let barcodeminX = barcode.cornerPoints![0].cgPointValue.x
21 let barcodeminY = barcode.cornerPoints![1].cgPointValue.y 21 let barcodeminY = barcode.cornerPoints![1].cgPointValue.y
22 22
@@ -24,7 +24,6 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin { @@ -24,7 +24,6 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin {
24 let barcodeheight = barcode.cornerPoints![3].cgPointValue.y - barcodeminY 24 let barcodeheight = barcode.cornerPoints![3].cgPointValue.y - barcodeminY
25 let barcodeBox = CGRect(x: barcodeminX, y: barcodeminY, width: barcodewidth, height: barcodeheight) 25 let barcodeBox = CGRect(x: barcodeminX, y: barcodeminY, width: barcodewidth, height: barcodeheight)
26 26
27 -  
28 let minX = scanwindow[0] * imageSize.width 27 let minX = scanwindow[0] * imageSize.width
29 let minY = scanwindow[1] * imageSize.height 28 let minY = scanwindow[1] * imageSize.height
30 29
@@ -40,8 +39,8 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin { @@ -40,8 +39,8 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin {
40 self.mobileScanner = MobileScanner(registry: registry, mobileScannerCallback: { barcodes, error, image in 39 self.mobileScanner = MobileScanner(registry: registry, mobileScannerCallback: { barcodes, error, image in
41 if barcodes != nil { 40 if barcodes != nil {
42 let barcodesMap: [Any?] = barcodes!.compactMap { barcode in 41 let barcodesMap: [Any?] = barcodes!.compactMap { barcode in
43 - if (SwiftMobileScannerPlugin.scanWindow != nil) {  
44 - if (SwiftMobileScannerPlugin.isBarcodeInScanWindow(barcode: barcode, imageSize: image.size)) { 42 + if (MobileScannerPlugin.scanWindow != nil) {
  43 + if (MobileScannerPlugin.isBarcodeInScanWindow(barcode: barcode, imageSize: image.size)) {
45 return barcode.data 44 return barcode.data
46 } else { 45 } else {
47 return nil 46 return nil
@@ -66,10 +65,9 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin { @@ -66,10 +65,9 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin {
66 } 65 }
67 66
68 public static func register(with registrar: FlutterPluginRegistrar) { 67 public static func register(with registrar: FlutterPluginRegistrar) {
69 - let instance = SwiftMobileScannerPlugin(barcodeHandler: BarcodeHandler(registrar: registrar), registry: registrar.textures())  
70 - let methodChannel = FlutterMethodChannel(name:  
71 - "dev.steenbakker.mobile_scanner/scanner/method", binaryMessenger: registrar.messenger())  
72 - registrar.addMethodCallDelegate(instance, channel: methodChannel) 68 + let channel = FlutterMethodChannel(name: "dev.steenbakker.mobile_scanner/scanner/method", binaryMessenger: registrar.messenger())
  69 + let instance = MobileScannerPlugin(barcodeHandler: BarcodeHandler(registrar: registrar), registry: registrar.textures())
  70 + registrar.addMethodCallDelegate(instance, channel: channel)
73 } 71 }
74 72
75 public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 73 public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
@@ -118,7 +116,6 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin { @@ -118,7 +116,6 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin {
118 barcodeOptions = BarcodeScannerOptions(formats: barcodeFormats) 116 barcodeOptions = BarcodeScannerOptions(formats: barcodeFormats)
119 } 117 }
120 118
121 -  
122 let position = facing == 0 ? AVCaptureDevice.Position.front : .back 119 let position = facing == 0 ? AVCaptureDevice.Position.front : .back
123 let detectionSpeed: DetectionSpeed = DetectionSpeed(rawValue: speed)! 120 let detectionSpeed: DetectionSpeed = DetectionSpeed(rawValue: speed)!
124 121
@@ -216,11 +213,10 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin { @@ -216,11 +213,10 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin {
216 result(nil) 213 result(nil)
217 } 214 }
218 215
219 -  
220 /// Toggles the torch 216 /// Toggles the torch
221 func updateScanWindow(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) { 217 func updateScanWindow(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
222 let scanWindowData: Array? = (call.arguments as? [String: Any])?["rect"] as? [CGFloat] 218 let scanWindowData: Array? = (call.arguments as? [String: Any])?["rect"] as? [CGFloat]
223 - SwiftMobileScannerPlugin.scanWindow = scanWindowData 219 + MobileScannerPlugin.scanWindow = scanWindowData
224 220
225 result(nil) 221 result(nil)
226 } 222 }
1 -//  
2 -// Util.swift  
3 -// camerax  
4 -//  
5 -// Created by 闫守旺 on 2021/2/6.  
6 -//  
7 -  
8 import AVFoundation 1 import AVFoundation
9 import Flutter 2 import Flutter
10 import Foundation 3 import Foundation
@@ -32,14 +32,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -32,14 +32,12 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
32 32
33 var symbologies:[VNBarcodeSymbology] = [] 33 var symbologies:[VNBarcodeSymbology] = []
34 34
35 -  
36 -// var analyzeMode: Int = 0 35 + // var analyzeMode: Int = 0
37 var analyzing: Bool = false 36 var analyzing: Bool = false
38 var position = AVCaptureDevice.Position.back 37 var position = AVCaptureDevice.Position.back
39 38
40 public static func register(with registrar: FlutterPluginRegistrar) { 39 public static func register(with registrar: FlutterPluginRegistrar) {
41 let instance = MobileScannerPlugin(registrar.textures) 40 let instance = MobileScannerPlugin(registrar.textures)
42 -  
43 let method = FlutterMethodChannel(name: 41 let method = FlutterMethodChannel(name:
44 "dev.steenbakker.mobile_scanner/scanner/method", binaryMessenger: registrar.messenger) 42 "dev.steenbakker.mobile_scanner/scanner/method", binaryMessenger: registrar.messenger)
45 let event = FlutterEventChannel(name: 43 let event = FlutterEventChannel(name:
@@ -53,7 +51,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -53,7 +51,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
53 super.init() 51 super.init()
54 } 52 }
55 53
56 -  
57 public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 54 public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
58 switch call.method { 55 switch call.method {
59 case "state": 56 case "state":
@@ -64,8 +61,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -64,8 +61,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
64 start(call, result) 61 start(call, result)
65 case "torch": 62 case "torch":
66 toggleTorch(call, result) 63 toggleTorch(call, result)
67 -// case "analyze":  
68 -// switchAnalyzeMode(call, result) 64 + // case "analyze":
  65 + // switchAnalyzeMode(call, result)
69 case "stop": 66 case "stop":
70 stop(result) 67 stop(result)
71 case "updateScanWindow": 68 case "updateScanWindow":
@@ -139,11 +136,11 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -139,11 +136,11 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
139 DispatchQueue.main.async { 136 DispatchQueue.main.async {
140 self?.sink?(["name": "barcodeMac", "data" : ["payload": barcode.payloadStringValue, "symbology": barcode.symbology.toInt as Any?]] as [String : Any]) 137 self?.sink?(["name": "barcodeMac", "data" : ["payload": barcode.payloadStringValue, "symbology": barcode.symbology.toInt as Any?]] as [String : Any])
141 } 138 }
142 -// if barcodeType == "QR" {  
143 -// let image = CIImage(image: source)  
144 -// image?.cropping(to: barcode.boundingBox)  
145 -// self.qrCodeDescriptor(qrCode: barcode, qrCodeImage: image!)  
146 -// } 139 + // if barcodeType == "QR" {
  140 + // let image = CIImage(image: source)
  141 + // image?.cropping(to: barcode.boundingBox)
  142 + // self.qrCodeDescriptor(qrCode: barcode, qrCodeImage: image!)
  143 + // }
147 } 144 }
148 } 145 }
149 } else { 146 } else {
@@ -204,9 +201,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -204,9 +201,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
204 } 201 }
205 202
206 func isBarCodeInScanWindow(_ scanWindow: CGRect, _ barcode: VNBarcodeObservation, _ inputImage: CGImage) -> Bool { 203 func isBarCodeInScanWindow(_ scanWindow: CGRect, _ barcode: VNBarcodeObservation, _ inputImage: CGImage) -> Bool {
207 -  
208 - let imageWidth = CGFloat(inputImage.width);  
209 - let imageHeight = CGFloat(inputImage.height); 204 + let imageWidth = CGFloat(inputImage.width)
  205 + let imageHeight = CGFloat(inputImage.height)
210 206
211 let minX = scanWindow.minX * imageWidth 207 let minX = scanWindow.minX * imageWidth
212 let minY = scanWindow.minY * imageHeight 208 let minY = scanWindow.minY * imageHeight
@@ -220,8 +216,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -220,8 +216,8 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
220 func isBarCodeInScanWindow(_ scanWindow: CGRect, _ barcode: VNBarcodeObservation, _ inputImage: CVImageBuffer) -> Bool { 216 func isBarCodeInScanWindow(_ scanWindow: CGRect, _ barcode: VNBarcodeObservation, _ inputImage: CVImageBuffer) -> Bool {
221 let size = CVImageBufferGetEncodedSize(inputImage) 217 let size = CVImageBufferGetEncodedSize(inputImage)
222 218
223 - let imageWidth = size.width;  
224 - let imageHeight = size.height; 219 + let imageWidth = size.width
  220 + let imageHeight = size.height
225 221
226 let minX = scanWindow.minX * imageWidth 222 let minX = scanWindow.minX * imageWidth
227 let minY = scanWindow.minY * imageHeight 223 let minY = scanWindow.minY * imageHeight
@@ -293,7 +289,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -293,7 +289,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
293 } catch { 289 } catch {
294 result(FlutterError(code: error.localizedDescription, message: nil, details: nil)) 290 result(FlutterError(code: error.localizedDescription, message: nil, details: nil))
295 } 291 }
296 - captureSession.sessionPreset = AVCaptureSession.Preset.photo; 292 + captureSession.sessionPreset = AVCaptureSession.Preset.photo
297 // Add video output. 293 // Add video output.
298 let videoOutput = AVCaptureVideoDataOutput() 294 let videoOutput = AVCaptureVideoDataOutput()
299 295
@@ -331,10 +327,10 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -331,10 +327,10 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
331 } 327 }
332 } 328 }
333 329
334 -// func switchAnalyzeMode(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {  
335 -// analyzeMode = call.arguments as! Int  
336 -// result(nil)  
337 -// } 330 + // func switchAnalyzeMode(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
  331 + // analyzeMode = call.arguments as! Int
  332 + // result(nil)
  333 + // }
338 334
339 func stop(_ result: FlutterResult) { 335 func stop(_ result: FlutterResult) {
340 if (device == nil) { 336 if (device == nil) {
@@ -352,7 +348,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -352,7 +348,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
352 device.removeObserver(self, forKeyPath: #keyPath(AVCaptureDevice.torchMode)) 348 device.removeObserver(self, forKeyPath: #keyPath(AVCaptureDevice.torchMode))
353 registry.unregisterTexture(textureId) 349 registry.unregisterTexture(textureId)
354 350
355 -// analyzeMode = 0 351 + // analyzeMode = 0
356 latestBuffer = nil 352 latestBuffer = nil
357 captureSession = nil 353 captureSession = nil
358 device = nil 354 device = nil
@@ -365,7 +361,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -365,7 +361,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
365 public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { 361 public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
366 switch keyPath { 362 switch keyPath {
367 case "torchMode": 363 case "torchMode":
368 - // off = 0; on = 1; auto = 2; 364 + // off = 0 on = 1 auto = 2
369 let state = change?[.newKey] as? Int 365 let state = change?[.newKey] as? Int
370 let event: [String: Any?] = ["name": "torchState", "data": state] 366 let event: [String: Any?] = ["name": "torchState", "data": state]
371 sink?(event) 367 sink?(event)
@@ -376,7 +372,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, @@ -376,7 +372,6 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
376 } 372 }
377 373
378 class MapArgumentReader { 374 class MapArgumentReader {
379 -  
380 let args: [String: Any]? 375 let args: [String: Any]?
381 376
382 init(_ args: [String: Any]?) { 377 init(_ args: [String: Any]?) {
@@ -422,7 +417,6 @@ class MapArgumentReader { @@ -422,7 +417,6 @@ class MapArgumentReader {
422 } 417 }
423 418
424 extension VNBarcodeSymbology { 419 extension VNBarcodeSymbology {
425 -  
426 static func fromInt(_ mapValue:Int) -> VNBarcodeSymbology? { 420 static func fromInt(_ mapValue:Int) -> VNBarcodeSymbology? {
427 if #available(macOS 12.0, *) { 421 if #available(macOS 12.0, *) {
428 if(mapValue == 8){ 422 if(mapValue == 8){
@@ -487,7 +481,7 @@ extension VNBarcodeSymbology { @@ -487,7 +481,7 @@ extension VNBarcodeSymbology {
487 case VNBarcodeSymbology.aztec: 481 case VNBarcodeSymbology.aztec:
488 return 4096 482 return 4096
489 default: 483 default:
490 - return -1; 484 + return -1
491 } 485 }
492 } 486 }
493 } 487 }