dzocesrce

Untitled

Apr 7th, 2026
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 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. final screenHeight = MediaQuery.of(context).size.height;
  19.  
  20. // 🔥 Responsive height with max cap
  21. final imageHeight =
  22. screenHeight * 0.32 > 420 ? 420.0 : screenHeight * 0.32;
  23.  
  24. return Center(
  25. child: Padding(
  26. padding: const EdgeInsets.all(24),
  27. child: Column(
  28. mainAxisSize: MainAxisSize.min,
  29. children: [
  30. if (imageAssetPath != null)
  31. Image.asset(
  32. imageAssetPath!,
  33. height: imageHeight,
  34. fit: BoxFit.contain,
  35. filterQuality: FilterQuality.high, // 👈 sharper image
  36. errorBuilder: (context, error, stackTrace) {
  37. return Icon(
  38. Icons.cloud_off,
  39. size: 72,
  40. color: colorScheme.outline,
  41. );
  42. },
  43. )
  44. else
  45. Icon(
  46. Icons.cloud_off,
  47. size: 72,
  48. color: colorScheme.outline,
  49. ),
  50.  
  51. SizedBox(height: screenHeight * 0.025),
  52.  
  53. Text(
  54. message,
  55. textAlign: TextAlign.center,
  56. style: Theme.of(context).textTheme.titleMedium,
  57. ),
  58.  
  59. if (onRetry != null) ...[
  60. SizedBox(height: screenHeight * 0.025),
  61. ElevatedButton(
  62. onPressed: onRetry,
  63. child: const Text('Retry'),
  64. ),
  65. ],
  66. ],
  67. ),
  68. ),
  69. );
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment