Skip to main content

flutter_zxing 4.0.0-rc.3 copy "flutter_zxing: ^4.0.0-rc.3" to clipboard
flutter_zxing: ^4.0.0-rc.3 copied to clipboard

Scan 32 barcode formats and create 30, QR codes included, on Android, iOS, macOS, Linux, Windows and the web with zxing-cpp. No ML Kit, no Play services.

example/example.md

Example #

A whole app: a button that scans a code, and the code shown again with BarcodeView. The example app in the repository has every template, the creator and a history.

import 'package:flutter/material.dart';
import 'package:flutter_zxing/scanner.dart';

void main() => runApp(const MaterialApp(home: HomePage()));

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  Barcode? _barcode;

  Future<void> _scan() async {
    final Barcode? barcode = await scanBarcode(context);
    if (barcode != null) setState(() => _barcode = barcode);
  }

  @override
  Widget build(BuildContext context) {
    final Barcode? barcode = _barcode;
    return Scaffold(
      appBar: AppBar(title: const Text('flutter_zxing')),
      body: Center(
        child: barcode == null
            ? const Text('Nothing scanned yet')
            : Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  BarcodeView(
                    barcode.text,
                    writer: barcode.format.canWrite
                        ? BarcodeWriter(barcode.format)
                        : const BarcodeWriter(BarcodeFormat.qrCode),
                    width: 240,
                  ),
                  const SizedBox(height: 16),
                  Text('${barcode.format.displayName}: ${barcode.content}'),
                ],
              ),
      ),
      floatingActionButton: FloatingActionButton.extended(
        onPressed: _scan,
        icon: const Icon(Icons.qr_code_scanner),
        label: const Text('Scan'),
      ),
    );
  }
}

For iOS, add NSCameraUsageDescription to ios/Runner/Info.plist; see Installation.

150
likes
160
points
69.9k
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Scan 32 barcode formats and create 30, QR codes included, on Android, iOS, macOS, Linux, Windows and the web with zxing-cpp. No ML Kit, no Play services.

Homepage
Repository (GitHub)
View/report issues

Topics

#barcode #qrcode #scanner #camera #zxing

License

MIT (license)

Dependencies

camera, camera_platform_interface, code_assets, ffi, flutter, hooks, image, image_picker, logging, native_toolchain_c, web

More

Packages that depend on flutter_zxing