Skip to content

Commit 49f1f03

Browse files
committed
feat(shared): Refactor FailureStateWidget to accept HtHttpException
1 parent e85579e commit 49f1f03

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:ht_dashboard/app/config/config.dart';
66
import 'package:ht_dashboard/bootstrap.dart';
77

88
// Define the current application environment (production/development/demo).
9-
const AppEnvironment appEnvironment = AppEnvironment.demo;
9+
const AppEnvironment appEnvironment = AppEnvironment.development;
1010

1111
@JS('removeSplashFromWeb')
1212
external void removeSplashFromWeb();

lib/shared/widgets/failure_state_widget.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
import 'package:flutter/material.dart';
2+
import 'package:ht_shared/ht_shared.dart';
3+
import 'package:ht_ui_kit/ht_ui_kit.dart';
24

35
/// A widget to display an error message and an optional retry button.
46
class FailureStateWidget extends StatelessWidget {
57
/// Creates a [FailureStateWidget].
68
///
7-
/// The [message] is the error message to display.
9+
/// The [exception] is the error exception to display.
810
///
911
/// The [onRetry] is an optional callback to be called
1012
/// when the retry button is pressed.
1113
const FailureStateWidget({
12-
required this.message,
14+
required this.exception,
1315
super.key,
1416
this.onRetry,
1517
this.retryButtonText,
1618
});
1719

18-
/// The error message to display.
19-
final String message;
20+
/// The error exception to display.
21+
final HtHttpException exception;
2022

2123
/// An optional callback to be called when the retry button is pressed.
2224
final VoidCallback? onRetry;
@@ -26,12 +28,13 @@ class FailureStateWidget extends StatelessWidget {
2628

2729
@override
2830
Widget build(BuildContext context) {
31+
final friendlyMessage = exception.toFriendlyMessage(context);
2932
return Center(
3033
child: Column(
3134
mainAxisAlignment: MainAxisAlignment.center,
3235
children: [
3336
Text(
34-
message,
37+
friendlyMessage,
3538
style: Theme.of(context).textTheme.bodyMedium,
3639
textAlign: TextAlign.center,
3740
),

0 commit comments

Comments
 (0)