easy_qr_scanner 0.0.2
easy_qr_scanner: ^0.0.2 copied to clipboard
A Flutter package for scanning QR codes using camera or image gallery.
import 'package:easy_qr_scanner/easy_qr_scanner.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'QR Scanner Demo',
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
String res = "";
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('QR Scanner')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
final result =await easyScanQRCode(context,title: "Find a QR code and scan it",
scanWindowBorderColor: Colors.green,
titleStyle: Theme.of(context).textTheme.bodyLarge?.copyWith(
fontWeight: FontWeight.w700,
fontSize: 11,
color: Colors.amber,
));
setState(() {
res = result.toString();
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Scanned result: $result')),
);
},
child: const Text("Scan QR Code")),
Text(res)
],
),
),
);
}
}