picklist_result.dart
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:mobile_scanner_example/picklist/barcode_scanner_picklist.dart';
class PicklistResult extends StatefulWidget {
const PicklistResult({super.key});
@override
State<PicklistResult> createState() => _PicklistResultState();
}
class _PicklistResultState extends State<PicklistResult> {
String barcode = 'Scan Something!';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Picklist result')),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(barcode),
ElevatedButton(
onPressed: () async {
final scannedBarcode =
await Navigator.of(context).push<Barcode>(
MaterialPageRoute(
builder: (context) => const BarcodeScannerPicklist(),
),
);
setState(
() {
if (scannedBarcode == null) {
barcode = 'Scan Something!';
return;
}
if (scannedBarcode.displayValue == null) {
barcode = '>>binary<<';
return;
}
barcode = scannedBarcode.displayValue!;
},
);
},
child: const Text('Scan'),
),
],
),
),
),
),
);
}
}