forked from Predidit/Kazumi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_widget.dart
71 lines (65 loc) · 1.72 KB
/
error_widget.dart
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
59
60
61
62
63
64
65
66
67
68
69
70
71
import 'package:flutter/material.dart';
class GeneralErrorWidget extends StatelessWidget {
const GeneralErrorWidget({
required this.errMsg,
this.actions,
super.key,
});
final String errMsg;
final List<Widget>? actions;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return ConstrainedBox(
constraints: BoxConstraints(
maxWidth: constraints.maxWidth * 2 / 3,
),
child: Text(
errMsg,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleSmall,
),
);
},
),
const SizedBox(height: 20),
if (actions != null)
Wrap(
alignment: WrapAlignment.center,
spacing: 8,
runSpacing: 8,
children: actions!,
),
],
);
}
}
class GeneralErrorButton extends StatelessWidget {
const GeneralErrorButton({
super.key,
required this.onPressed,
required this.text,
});
final Function() onPressed;
final String text;
@override
Widget build(BuildContext context) {
return FilledButton.tonal(
onPressed: onPressed,
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith((_) {
return Theme.of(context).colorScheme.primary.withAlpha(20);
}),
),
child: Text(
text,
style: TextStyle(color: Theme.of(context).colorScheme.primary),
),
);
}
}