Aus öffentlichen Paketdaten erstellte Orientierung.
Ein plattformübergreifender QR-Code-Scanner für Flutter-Anwendungen, der einen auf Dart basierenden Decoder nutzt, um nahtlos sowohl unter Android als auch unter iOS zu funktionieren. Er ermöglicht Echtzeit-Scanning ohne Abhängigkeit von nativen Kamera-APIs und bietet eine leichtgewichtige und effiziente Lösung zur direkten Integration von QR-Code-Funktionen in Dart. Das Paket ist ideal für Anwendungen, die eine schnelle Datenextraktion aus QR-Codes erfordern, beispielsweise bei Ticketing, Authentifizierung oder Produktinformationen. Mit Fokus auf Einfachheit entwickelt, bietet es eine einfache Integration und zuverlässige Decodierleistung.
Anwendungsfälle
QR-Codes in mobilen Apps scannen
Digitale Ticketüberprüfung
Produktinformationenabruf
Benutzerauthentifizierung über QR
Schneller Datentransfer zwischen Geräten
Hauptmerkmale
Plattformübergreifende Unterstützung (iOS und Android)
Dart-native Decoding-Engine
Leicht und schnell
Einfache API-Integration
Echtzeit-Scankapazität
Geeignet für
Entwickler, die mobile Apps mit QR-Scanning-Anforderungen erstellen
Apps, die eine Offline-QR-Decodierung erfordern
Projekte, die native Kamerabedingungen vermeiden
Hinweise
Beschränkt auf QR-Codes (keine Barcode)
Die Leistung hängt von der Kamerabildqualität des Geräts ab
Kann Kameraberechtigungen erfordern
Keine eingebaute Benutzeroberfläche — erfordert benutzerdefinierte Implementierung
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
QRCodeDartScan
A QR code scanner that works on both iOS and Android using dart decoder.
iOS 10.0 of higher is needed to use the camera plugin. If compiling for any version lower than 10.0 make sure to check the iOS version before using the camera plugin. For example, using the device_info plugin.
Add two rows to the ios/Runner/Info.plist:
one with the key Privacy - Camera Usage Description and a usage description.
and one with the key Privacy - Microphone Usage Description and a usage description.
Or in text format add the key:
<key>NSCameraUsageDescription</key><string>Can I use the camera please?</string><key>NSMicrophoneUsageDescription</key><string>Can I use the mic please?</string>
Android
Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.
minSdkVersion 21
It's important to note that the MediaRecorder class is not working properly on emulators, as stated in the documentation: https://developer.android.com/reference/android/media/MediaRecorder. Specifically, when recording a video with sound enabled and trying to play it back, the duration won't be correct and you will only see the first frame.
returnScaffold(
body: QRCodeDartScanView(
onCameraError: (String error) {
debugPrint('Error: $error');
},
// cropRect: CropRect(left: 0, top: 0, width: 100, height: 100), // You can crop the image to improve accuracy by specifying a rectangle region. ( default = null)// imageDecodeOrientation: ImageDecodeOrientation.original, // you can force how the image orientation will be decoded (default = original)
typeScan: TypeScan.live, // if TypeScan.takePicture will try decode when click to take a picture(default TypeScan.live)// intervalScan: const Duration(seconds:1)// onResultInterceptor: (old,new){// do any rule to controll onCapture.// }// takePictureButtonBuilder: (context,controller,isLoading){ // if typeScan == TypeScan.takePicture you can customize the button.// if(loading) return CircularProgressIndicator();// return ElevatedButton(// onPressed:controller.takePictureAndDecode,// child:Text('Take a picture'),// );// }// resolutionPreset: = QrCodeDartScanResolutionPreset.high,// formats: [ // You can restrict specific formats.// BarcodeFormat.qrCode,// BarcodeFormat.aztec,// BarcodeFormat.dataMatrix,// BarcodeFormat.pdf417,// BarcodeFormat.code39,// BarcodeFormat.code93,// BarcodeFormat.code128,// BarcodeFormat.ean8,// BarcodeFormat.ean13,// ],// croppingStrategy: CroppingStrategy.cropCenterSquare(// squareSizeFactor: 0.7,// ),
onCapture: (ScanResult result) {
// do anything with result// result.text -> String// result.format -> BarcodeFormat// result.corners -> List<Point<double>>, in camera preview// coordinates. Use `result.corners.toOffsets`// to paint them.// result.rawBytes -> Uint8List?// result.timestamp -> DateTime
},
),
);
ATTENTION
Always use this package in portrait mode.
There is a bug in the camera plugin that sometimes the image is rotated 90 degrees, to avoid this problem, you can use the imageDecodeOrientation parameter to force the image to be decoded in the correct orientation.
For example, if you are reading an ITF code, you can force the image to be decoded in landscape orientation.
The decoder process is done in dart code. So, in flutter debug mode, you will not have a good performance. But in release mode, the performance is very better.