Search code examples
flutterdartdart-pub

Flutter cannot find module barcode_scan;


i'm new to flutter and try to create a barcode app. To Scan barcodes i'm using this library: barcode_scan: "^0.0.4". On Android everything is working fine but xcode cannot find my module. I think i'm doing something wrong because some of my packages werent found only in xcode. The way i added those dependencies was, i added the dependencies into my pubspec.yaml file like this:

dependencies:
 flutter:
  sdk: flutter

 cupertino_icons: ^0.1.2
 barcode_scan: "^0.0.4"
 url_launcher:
 validators:
 flutter_launcher_icons: ^0.7.2

Afterwards i run pub get on android studio. Did i forgot something on the ios side? My Project includes swift support. Thanks


Solution

  • To use on iOS, you must add the the camera usage description to your Info.plist

    <dict>
        <!-- ... -->
        <key>NSCameraUsageDescription</key>
        <string>Camera permission is required for barcode scanning.</string>
        <!-- ... -->
    </dict>
    

    Also try to use the latest version of the barcode_scan plugin in your pubspec.yaml file:

    dependencies:
        # ...
        barcode_scan: any
    

    Latest version had some additional implementation works in Android. Check the official doc here