scanner_error_widget.dart
1.07 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
import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
class ScannerErrorWidget extends StatelessWidget {
const ScannerErrorWidget({super.key, required this.error});
final MobileScannerException error;
@override
Widget build(BuildContext context) {
return ColoredBox(
color: Colors.black,
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Padding(
padding: EdgeInsets.only(bottom: 16),
child: Icon(Icons.error, color: Colors.white),
),
Text(
error.errorCode.message,
style: const TextStyle(color: Colors.white),
),
if (error.errorDetails?.message case final String message) Text(
message,
style: const TextStyle(color: Colors.white),
),
error.errorDetails!.message ?? '',
style: const TextStyle(color: Colors.white),
),
],
),
),
);
}
}