flexible_barcode_scanner 0.0.6 copy "flexible_barcode_scanner: ^0.0.6" to clipboard
flexible_barcode_scanner: ^0.0.6 copied to clipboard

A highly customizable Flutter package for integrating a barcode scanner into your applications.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flexible_barcode_scanner/flexible_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 Barcode Scanner',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Barcode Scanner'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

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

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

  void _scanBarcode() async {
    final resultbarcode =
        await scanBarcode(context, backButtonBackgroundColor: Colors.red);
    setState(() {
      if (resultbarcode != "-1") {
        barcode = resultbarcode;
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Below, the scanned barcode information will appear:',
            ),
            Text(
              barcode,
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _scanBarcode,
        tooltip: 'Increment',
        child: const Icon(Icons.barcode_reader),
      ),
    );
  }
}
3
likes
0
points
105
downloads

Publisher

verified publisherdevastral.tr

Weekly Downloads

A highly customizable Flutter package for integrating a barcode scanner into your applications.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

camera, flutter

More

Packages that depend on flexible_barcode_scanner