flutter_pro_barcode_scanner 0.0.1 copy "flutter_pro_barcode_scanner: ^0.0.1" to clipboard
flutter_pro_barcode_scanner: ^0.0.1 copied to clipboard

A Flutter package for scanning barcode and QR codes in Mobile and Web Application.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

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

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String code = "";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text(
          "Flutter Pro Barcode Scanner",
          style: TextStyle(color: Colors.white),
        ),
        actions: [
          IconButton(
            onPressed: () async {
              String scannedCode = await Navigator.push(
                  context,
                  MaterialPageRoute(
                      builder: (context) => const ScannerScreen()));
              print(scannedCode);
              setState(() {
                code = scannedCode;
              });
            },
            icon: const Icon(
              Icons.qr_code_scanner_rounded,
              color: Colors.white,
            ),
          )
        ],
      ),
      body: Center(
        child: SingleChildScrollView(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Visibility(
                    visible: code.isNotEmpty,
                    replacement: const Text(
                      'Scan Code from App Bar',
                    ),
                    child: const Text(
                      'Scanned Code Value:',
                    )),
                if (code.isNotEmpty)
                  Text(
                    code,
                    style: Theme.of(context).textTheme.headlineMedium,
                  ),
                const SizedBox(height: 20),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
5
likes
150
points
399
downloads

Publisher

verified publishervirvainfotech.com

Weekly Downloads

A Flutter package for scanning barcode and QR codes in Mobile and Web Application.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, qr_code_scanner

More

Packages that depend on flutter_pro_barcode_scanner