code_scan 0.4.10 copy "code_scan: ^0.4.10" to clipboard
code_scan: ^0.4.10 copied to clipboard

A flexible code scanner for QR codes, barcodes and many others. Using Google's ML Kit. Use it as a Widget with a camera or use the methods provided, with a camera controller.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:code_scan/code_scan.dart';

void main() async {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
  String? code;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: code == null
            ? CodeScanner(
                onScan: (code, details, controller) =>
                    setState(() => this.code = code),
                onScanAll: (codes, controller) => print(
                    'Codes: ' + codes.map((code) => code.rawValue).toString()),
                formats: const [BarcodeFormat.qrCode],
                once: true,
              )
            : GestureDetector(
                onTap: () => setState(() => code = null),
                child: Container(
                  color: Colors.transparent,
                  child: Center(child: Text(code!)),
                ),
              ),
      ),
    );
  }
}
15
likes
130
pub points
82%
popularity

Publisher

verified publisherdrafakiller.com

A flexible code scanner for QR codes, barcodes and many others. Using Google's ML Kit. Use it as a Widget with a camera or use the methods provided, with a camera controller.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

camera, flutter, google_mlkit_barcode_scanning, rxdart

More

Packages that depend on code_scan