zp_qr_scanner 1.0.2
zp_qr_scanner: ^1.0.2 copied to clipboard
A high-performance Flutter QR and barcode scanner plugin powered by iOS native camera textures.
zp_qr_scanner #
A high-performance Flutter QR and barcode scanner plugin powered by iOS native camera textures (AVFoundation + Flutter TextureRegistry).
✨ Features #
- ⚡ High Performance: Native camera texture streaming directly into Flutter via
Texture(textureId: ...), avoiding expensive platform view and image conversion overhead. - 🎯 Smooth Real-time Tracking: Automatically detects and tracks QR corners with smooth bounding box and scanning animations.
- 🔦 Torch & Focus Controls: Built-in support for toggling flashlight and manual tap-to-focus.
- 📳 Haptic Feedback: Built-in haptic feedback on successful scans.
- 📱 Low Memory & Battery Efficient: Clean lifecycle management with automatic resume and pause.
🚀 Getting Started #
1. Add dependency #
Add zp_qr_scanner to your pubspec.yaml:
dependencies:
zp_qr_scanner: ^1.0.0
Or install it via CLI:
flutter pub add zp_qr_scanner
2. Platform Setup #
iOS Setup
Add the camera permission description to your ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>We need access to your camera to scan QR codes and barcodes.</string>
Note: Requires iOS 15.5 or higher.
📖 Usage #
Basic Scanner View #
Use QrScannerView to display a full-featured scanner screen:
import 'package:flutter/material.dart';
import 'package:zp_qr_scanner/zp_qr_scanner.dart';
class ScanPage extends StatelessWidget {
const ScanPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: QrScannerView(
onScanned: (String value) async {
// Handle scan result
await showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: const Text('Scanned Result'),
content: Text(value),
actions: [
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('OK'),
),
],
),
);
// Once the Future finishes, scanner resumes automatically!
},
),
);
}
}
Low-level API (ZpQrScanner) #
If you want custom UI or manual camera control:
// Start camera session and get texture metadata
final QrTexture texture = await ZpQrScanner.start();
print('Texture ID: ${texture.id}, Size: ${texture.size}');
// Listen to scanned results stream
final subscription = ZpQrScanner.results.listen((QrScanResult result) {
print('Scanned value: ${result.value}');
print('Corners: ${result.corners}');
});
// Toggle torch / flashlight
await ZpQrScanner.setTorch(true);
// Focus at a specific point (normalized 0.0 - 1.0)
await ZpQrScanner.focus(const Offset(0.5, 0.5));
// Pause and resume
await ZpQrScanner.stop();
await ZpQrScanner.resume();
🛠️ Example #
Check out the complete sample project in the example/ directory.
📄 License #
This project is licensed under the MIT License - see the LICENSE file for details.