flutter_scanner_package 0.0.2
flutter_scanner_package: ^0.0.2 copied to clipboard
A new Flutter package for QR Code and Bar Code
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_scanner_package/flutter_scanner_package.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Scanner Package Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Scanner Package Demo'),
);
}
}
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 _scanBarcode = 'Unknown';
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
alignment: Alignment.center,
child: Scrollbar(
child: Flex(
direction: Axis.vertical,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 200.0,
height: 300.0,
child: CustomScanner(
type: 'QR Code',
scanResult: (result) => {
setState(() {
_scanBarcode = result;
})
}),
),
SizedBox(
width: 400.0,
height: 300.0,
child: Text('Scan result : $_scanBarcode\n',
style: const TextStyle(fontSize: 20)))
]),
)));
}
}