barcode_scan2
4.9.0, released 9 days ago by mono0926.com
A flutter plugin for scanning 2D barcodes and QRCodes via camera.
What it does
A Flutter plugin that provides a simple wrapper around iOS and Android libraries to scan 2D barcodes and QR codes. It handles camera permissions and provides options to control flash and restrict barcode formats.
AI-written summary of version 4.8.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a straightforward, modal-based barcode and QR code scanner.
- You need to quickly capture barcode string data with minimal UI customization.
Skip it when
- You need an embedded widget preview inside your own custom UI rather than a full-screen scanner view.
- You want a pure Dart implementation without native library wrappers.
Strengths
- Simple API with a single `BarcodeScanner.scan()` method call.
- Built-in permission handling and flash control options.
Weaknesses
- Relies on older underlying native libraries (MTBBarcodeScanner and barcodescanner).
- Limited to full-screen scanning flows rather than embedded widget views.
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 1
Requires adding CAMERA permission to AndroidManifest.xml and NSCameraUsageDescription to Info.plist on iOS. Android requires Kotlin configuration.
import 'package:barcode_scan2/barcode_scan2.dart';
void main() async {
var result = await BarcodeScanner.scan();
print(result.type);
print(result.rawContent);
print(result.format);
}Alternatives
Packages that do the same job and could replace barcode_scan2.
- mobile_scanner
Provides a widget-based scanner view that can be embedded anywhere in your widget tree.
95Compare - google_mlkit_barcode_scanning
Uses Google's ML Kit for powerful on-device barcode and QR code detection.
94Compare
Works with
Packages commonly used together with barcode_scan2: ones it builds on, ones built on it, and its own family.