1
1
import 'package:flutter/material.dart' ;
2
+ import 'package:ht_shared/ht_shared.dart' ;
3
+ import 'package:ht_ui_kit/ht_ui_kit.dart' ;
2
4
3
5
/// A widget to display an error message and an optional retry button.
4
6
class FailureStateWidget extends StatelessWidget {
5
7
/// Creates a [FailureStateWidget] .
6
8
///
7
- /// The [message ] is the error message to display.
9
+ /// The [exception ] is the error exception to display.
8
10
///
9
11
/// The [onRetry] is an optional callback to be called
10
12
/// when the retry button is pressed.
11
13
const FailureStateWidget ({
12
- required this .message ,
14
+ required this .exception ,
13
15
super .key,
14
16
this .onRetry,
15
17
this .retryButtonText,
16
18
});
17
19
18
- /// The error message to display.
19
- final String message ;
20
+ /// The error exception to display.
21
+ final HtHttpException exception ;
20
22
21
23
/// An optional callback to be called when the retry button is pressed.
22
24
final VoidCallback ? onRetry;
@@ -26,12 +28,13 @@ class FailureStateWidget extends StatelessWidget {
26
28
27
29
@override
28
30
Widget build (BuildContext context) {
31
+ final friendlyMessage = exception.toFriendlyMessage (context);
29
32
return Center (
30
33
child: Column (
31
34
mainAxisAlignment: MainAxisAlignment .center,
32
35
children: [
33
36
Text (
34
- message ,
37
+ friendlyMessage ,
35
38
style: Theme .of (context).textTheme.bodyMedium,
36
39
textAlign: TextAlign .center,
37
40
),
0 commit comments