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

outdated

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!)),
                ),
              ),
      ),
    );
  }
}
17
likes
0
pub points
81%
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

License

unknown (license)

Dependencies

camera, flutter, google_mlkit_barcode_scanning, rxdart

More

Packages that depend on code_scan