Package selection guidance compiled from public package information, community data, and project usage.
barcode_scan2 is a Flutter plugin that enables scanning of 2D barcodes and QR codes using the device's camera. It provides a simple, reliable interface for integrating barcode scanning functionality into Flutter applications. The plugin supports both Android and iOS platforms, making it suitable for cross-platform mobile development. With minimal setup, developers can quickly add scanning capabilities to apps used in retail, logistics, ticketing, and more. The source code is publicly available on GitHub for transparency and customization.
Use cases
Retail inventory management
Event ticket scanning
Product information lookup
Logistics tracking
User authentication via QR codes
Key features
Real-time barcode scanning
Support for 2D barcodes and QR codes
Cross-platform compatibility (Android & iOS)
Simple integration with Flutter
Open-source and customizable
Suitable for
Mobile apps needing barcode scanning
Developers building inventory or ticketing systems
Projects requiring quick QR code data retrieval
Apps targeting both Android and iOS users
Considerations
Requires camera permissions on both platforms
May need additional UI components for optimal user experience
Performance depends on device camera quality
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
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