flutter_zxing
Scan and create QR codes and barcodes in Flutter.
32 formats on Android, iOS, macOS, Linux, Windows and the web, a ready-made
scanner you can brand, and styled codes to show, export and print.
Powered by zxing-cpp: no ML Kit, no Google Play services, no network.
Features
- A complete scanner in one line. 16 ready-made templates (payments, tickets, check-in, retail, pharma, logistics, kiosk…) with a result sheet, or just the camera and your own UI.
- Your brand's look. Accent, scan window, scan line, glass, buttons, icons and text styles; texts in English, Russian, German, Spanish, French and Chinese, following the app's language.
- 32 formats to read, 30 to create, the same on every platform, including Micro QR, rMQR, DataBar, MaxiCode and MicroPDF417, which ML Kit does not read.
- Knows what is inside. URLs, Wi‑Fi, contacts, events, payments (SEPA, Swiss QR-bill, UPI, PIX…), GS1, boarding passes, driver's licenses and more, as Dart types; and builds them back into codes.
- Barcodes as widgets. Sharp at any size, with colors, gradients, rounded or dot modules and a logo; exported to PNG and SVG, or laid out on label sheets as PDF.
- Private and fast. Everything runs on the device, off the UI thread, in WebAssembly on the web. Every camera frame is decoded in 2–4 ms.
Quick start
flutter pub add flutter_zxing
import 'package:flutter_zxing/scanner.dart';
// Scan one code and come back with it (null if the user closes the scanner).
final Barcode? barcode = await scanBarcode(context);
// A scanner screen in your own page: camera, buttons, hints and a result sheet.
BarcodeScanner(
template: const ScannerTemplate.minimal(),
onDetect: (capture) => print(capture.barcode.text),
)
// A QR code.
const BarcodeView('https://pub.dev/packages/flutter_zxing', width: 200)
scanner.dart is the whole 4.0 API; flutter_zxing.dart adds the
deprecated 3.x API. No CMake, CocoaPods or Gradle setup: a build hook
compiles the engine.
Requires Flutter 3.41 or newer. Add the camera permission on
iOS and Android,
and see Platforms
for the web and desktop.
Documentation
| Scanning | Scan one code · Templates · Colours and texts · Your own UI · The controller |
| Images | Read an image · Reader options |
| Creating | Barcodes as widgets · Styles and logos · PNG and SVG · Label sheets · Many codes |
| Content | What is in a code · Payments · Building content |
| Recipes | Use cases: 26 screens to copy, from tickets at the door to a Wi‑Fi card for guests |
| Reference | Formats · Accuracy and speed · API reference |
Platforms
| Android | iOS | Web | macOS | Linux | Windows | |
|---|---|---|---|---|---|---|
| Read images and create codes | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Camera scanner | ✅ | ✅ | ✅ | ✅ ᶜ | ✅ ᶜ | ✅ ᶜ |
ᶜ with camera_desktop.
The web runs the same engine as WebAssembly in a Web Worker, in Chrome,
Safari and Firefox.
Performance
- Every camera frame decoded: 30 per second on an iPhone 17 Pro Max, 25 on a Pixel 4a (2020), no frame skipped and no UI frame late.
- A 12-megapixel photo with a small QR code is read in about 0.1 s on a MacBook and 0.2 s on a Pixel 4a, without blocking the UI.
- Small: +2.7 MB per Android ABI, +1.0 MB on iOS, 312 KB on the web.
All numbers and how they were measured: Accuracy and speed.
Why flutter_zxing
Choose it when Google services, offline use or privacy matter, when you need formats ML Kit does not read, Linux or Windows, the same results on every platform, or scanning and generation in one package. Machine-learning scanners such as mobile_scanner read damaged and far-away codes better; the honest comparison covers both sides and maps its API to ours.
Upgrading from 3.x
The 3.x API keeps working in 4.x on the new engine, deprecated until 5.0; each deprecated name points to its replacement. See Upgrading from 3.x and the CHANGELOG.
Contributing
Bug reports, ideas and pull requests are welcome. See CONTRIBUTING.md to build the package and run the demo and the tests.
License
MIT, see LICENSE. zxing-cpp is licensed under Apache 2.0.
Libraries
- content
- Barcode payloads as typed values:
barcode.contentparses a URL, a Wi-Fi network, a contact, an event, GS1 data and so on. - core
- The core of flutter_zxing: zxing-cpp for Flutter.
- flutter_zxing
- Reads and creates barcodes on Android, iOS, macOS, Linux, Windows and the web, with zxing-cpp.
- rendering
- Barcodes on screen and in files with colors, shapes and a logo: BarcodeView and BarcodeStyle; pages of labels to print: BarcodeLabelSheet.
- scanner
- The camera scanner: BarcodeScanner with templates and themes, its ScannerController, and the glass widgets to build your own scanner UI.