Julian Steenbakker
Committed by GitHub

Merge pull request #268 from jorgenpt/support-multiple-formats-on-ios

fix: Add support for multiple formats on iOS
@@ -195,13 +195,13 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHan @@ -195,13 +195,13 @@ public class SwiftMobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHan
195 let facing: Int = argReader.int(key: "facing") ?? 1 195 let facing: Int = argReader.int(key: "facing") ?? 1
196 let formats: Array = argReader.intArray(key: "formats") ?? [] 196 let formats: Array = argReader.intArray(key: "formats") ?? []
197 197
198 - let formatList: NSMutableArray = [] 198 + if (formats.count != 0) {
  199 + var barcodeFormats: BarcodeFormat = []
199 for index in formats { 200 for index in formats {
200 - formatList.add(BarcodeFormat(rawValue: index)) 201 + barcodeFormats.insert(BarcodeFormat(rawValue: index))
201 } 202 }
202 203
203 - if (formatList.count != 0) {  
204 - let barcodeOptions = BarcodeScannerOptions(formats: formatList.firstObject as! BarcodeFormat) 204 + let barcodeOptions = BarcodeScannerOptions(formats: barcodeFormats)
205 scanner = BarcodeScanner.barcodeScanner(options: barcodeOptions) 205 scanner = BarcodeScanner.barcodeScanner(options: barcodeOptions)
206 } 206 }
207 207
@@ -49,8 +49,6 @@ class MobileScannerController { @@ -49,8 +49,6 @@ class MobileScannerController {
49 final bool returnImage; 49 final bool returnImage;
50 50
51 /// If provided, the scanner will only detect those specific formats. 51 /// If provided, the scanner will only detect those specific formats.
52 - ///  
53 - /// WARNING: On iOS, only 1 format is supported.  
54 final List<BarcodeFormat>? formats; 52 final List<BarcodeFormat>? formats;
55 53
56 CameraFacing facing; 54 CameraFacing facing;