code_scan 0.1.0 copy "code_scan: ^0.1.0" to clipboard
code_scan: ^0.1.0 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 camera or use the methods provided, with whatever camera widget.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:code_scan/code_scan.dart';
import 'package:google_mlkit_barcode_scanning/google_mlkit_barcode_scanning.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: [BarcodeFormat.qrCode],
                once: true,
              )
            : GestureDetector(
                onTap: () => setState(() => this.code = null),
                child: Container(
                  color: Colors.transparent,
                  child: Center(child: Text(code!)),
                ),
              ),
      ),
    );
  }
}
16
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 camera or use the methods provided, with whatever camera widget.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

camera, flutter, google_mlkit_barcode_scanning, rxdart

More

Packages that depend on code_scan