Aus öffentlichen Paketdaten erstellte Orientierung.
barcode_scan2 ist ein Flutter-Plugin, das die Scannung von 2D-Barcodes und QR-Codes mit der Kamera des Geräts ermöglicht. Es bietet eine einfache, zuverlässige Schnittstelle zur Integration von Barcode-Scanning-Funktionen in Flutter-Anwendungen. Das Plugin unterstützt sowohl Android als auch iOS und ist somit für plattformübergreifende mobile Entwicklung geeignet. Mit minimalem Aufwand können Entwickler schnell Scan-Funktionen in Anwendungen für Einzelhandel, Logistik, Ticketing und mehr integrieren. Der Quellcode ist öffentlich auf GitHub verfügbar, um Transparenz und Anpassung zu gewährleisten.
Now you can depend on the barcode_scan plugin in your pubspec.yaml file:
dependencies:# ...barcode_scan2:any
Click "Packages get" in Android Studio or run flutter packages get in your project folder.
iOS
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>
iOS 26+ Compatibility
This fork includes a fix for the 10-15 second delay when dismissing the scanner on iOS 26+. The fix is built-in - no additional configuration required.
Usage
import'package:barcode_scan2/barcode_scan2.dart';
voidmain() async {
var result = awaitBarcodeScanner.scan();
print(result.type); // The result type (barcode, cancelled, failed)print(result.rawContent); // The barcode contentprint(result.format); // The barcode format (as enum)print(result.formatNote); // If a unknown format was scanned this field contains a note
}
Advanced usage
You can pass options to the scan method:
import'package:barcode_scan2/barcode_scan2.dart';
voidmain() async {
var options = ScanOptions(
// set the options
);
var result = awaitBarcodeScanner.scan(options: options);
// ...
}
Supported options
Option
Type
Description
Supported by
strings.cancel
String
The cancel button text on iOS
iOS only
strings.flash_on
String
The flash on button text
iOS + Android
strings.flash_off
String
The flash off button text
iOS + Android
restrictFormat
BarcodeFormat[]
Restrict the formats which are recognized
iOS + Android
useCamera
int
The index of the camera which is used for scanning (See BarcodeScanner.numberOfCameras)
iOS + Android
autoEnableFlash
bool
Enable the flash when start scanning
iOS + Android
android.aspectTolerance
double
Enable auto focus on Android
Android only
android.useAutoFocus
bool
Set aspect ratio tolerance level used in calculating the optimal Camera preview size