qr_code_dart_scan 0.5.0 qr_code_dart_scan: ^0.5.0 copied to clipboard
A QR code scanner that works on both iOS and Android using dart decoder.
import 'package:flutter/material.dart';
import 'package:qr_code_dart_scan/qr_code_dart_scan.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Result? currentResult;
@override
Widget build(BuildContext context) {
return Scaffold(
body: QRCodeDartScanView(
scanInvertedQRCode: true,
onCapture: (Result result) {
setState(() {
currentResult = result;
});
},
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.all(20),
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Text: ${currentResult?.text ?? 'Not found'}'),
Text('Format: ${currentResult?.barcodeFormat ?? 'Not found'}'),
],
),
),
),
),
);
}
}