Skip to content

Commit 4d81041

Browse files
committed
feat: Add custom retry button text to failure widget
- Added retryButtonText parameter - Allows custom text on retry button
1 parent 962e166 commit 4d81041

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/shared/widgets/failure_state_widget.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@ class FailureStateWidget extends StatelessWidget {
88
///
99
/// The [onRetry] is an optional callback to be called
1010
/// when the retry button is pressed.
11-
const FailureStateWidget({required this.message, super.key, this.onRetry});
11+
const FailureStateWidget({
12+
required this.message,
13+
super.key,
14+
this.onRetry,
15+
this.retryButtonText, // Optional custom text for the retry button
16+
});
1217

1318
/// The error message to display.
1419
final String message;
1520

1621
/// An optional callback to be called when the retry button is pressed.
1722
final VoidCallback? onRetry;
1823

24+
/// Optional custom text for the retry button. Defaults to "Retry".
25+
final String? retryButtonText;
26+
1927
@override
2028
Widget build(BuildContext context) {
2129
return Center(
@@ -33,7 +41,7 @@ class FailureStateWidget extends StatelessWidget {
3341
padding: const EdgeInsets.only(top: 16),
3442
child: ElevatedButton(
3543
onPressed: onRetry,
36-
child: const Text('Retry'),
44+
child: Text(retryButtonText ?? 'Retry'), // Use custom text or default
3745
),
3846
),
3947
],

0 commit comments

Comments
 (0)