dzocesrce

Untitled

Apr 7th, 2026
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. import 'app_surface_styles.dart';
  4.  
  5. class AppErrorState extends StatelessWidget {
  6. final String message;
  7. final VoidCallback? onRetry;
  8. final String? imageAssetPath;
  9.  
  10. const AppErrorState({
  11. super.key,
  12. required this.message,
  13. this.onRetry,
  14. this.imageAssetPath,
  15. });
  16.  
  17. @override
  18. Widget build(BuildContext context) {
  19. final colorScheme = Theme.of(context).colorScheme;
  20. final screenHeight = MediaQuery.of(context).size.height;
  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,
  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. SizedBox(height: screenHeight * 0.025),
  51. Text(
  52. message,
  53. textAlign: TextAlign.center,
  54. style: Theme.of(context).textTheme.titleMedium,
  55. ),
  56. if (onRetry != null) ...[
  57. SizedBox(height: screenHeight * 0.025),
  58. Material(
  59. color: Colors.transparent,
  60. child: InkWell(
  61. onTap: onRetry,
  62. borderRadius: BorderRadius.circular(14),
  63. child: Container(
  64. padding: const EdgeInsets.symmetric(
  65. horizontal: 22,
  66. vertical: 12,
  67. ),
  68. decoration: AppSurfaceStyles.card(
  69. context,
  70. backgroundColor: Colors.transparent,
  71. radius: 14,
  72. isHighlighted: true,
  73. ),
  74. child: Text(
  75. 'Retry',
  76. style: Theme.of(context).textTheme.titleMedium?.copyWith(
  77. fontWeight: FontWeight.w600,
  78. color: colorScheme.primary,
  79. ),
  80. ),
  81. ),
  82. ),
  83. ),
  84. ],
  85. ],
  86. ),
  87. ),
  88. );
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment