dzocesrce

Untitled

Apr 7th, 2026
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class AppErrorState extends StatelessWidget {
  4. final String message;
  5. final VoidCallback? onRetry;
  6. final String? imageAssetPath;
  7.  
  8. const AppErrorState({
  9. super.key,
  10. required this.message,
  11. this.onRetry,
  12. this.imageAssetPath,
  13. });
  14.  
  15. @override
  16. Widget build(BuildContext context) {
  17. final colorScheme = Theme.of(context).colorScheme;
  18.  
  19. return Center(
  20. child: Padding(
  21. padding: const EdgeInsets.all(24),
  22. child: Column(
  23. mainAxisSize: MainAxisSize.min,
  24. children: [
  25. if (imageAssetPath != null)
  26. Image.asset(
  27. imageAssetPath!,
  28. height: 450,
  29. fit: BoxFit.contain,
  30. errorBuilder: (context, error, stackTrace) {
  31. return Icon(
  32. Icons.cloud_off,
  33. size: 72,
  34. color: colorScheme.outline,
  35. );
  36. },
  37. )
  38. else
  39. Icon(
  40. Icons.cloud_off,
  41. size: 72,
  42. color: colorScheme.outline,
  43. ),
  44. const SizedBox(height: 18),
  45. Text(
  46. message,
  47. textAlign: TextAlign.center,
  48. style: Theme.of(context).textTheme.titleMedium,
  49. ),
  50. if (onRetry != null) ...[
  51. const SizedBox(height: 18),
  52. ElevatedButton(
  53. onPressed: onRetry,
  54. child: const Text('Retry'),
  55. ),
  56. ],
  57. ],
  58. ),
  59. ),
  60. );
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment