dzocesrce

Untitled

Apr 7th, 2026
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 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. final buttonBackground = Theme.of(context).scaffoldBackgroundColor;
  25.  
  26. return Center(
  27. child: Padding(
  28. padding: const EdgeInsets.all(24),
  29. child: Column(
  30. mainAxisSize: MainAxisSize.min,
  31. children: [
  32. if (imageAssetPath != null)
  33. Image.asset(
  34. imageAssetPath!,
  35. height: imageHeight,
  36. fit: BoxFit.contain,
  37. filterQuality: FilterQuality.high,
  38. errorBuilder: (context, error, stackTrace) {
  39. return Icon(
  40. Icons.cloud_off,
  41. size: 72,
  42. color: colorScheme.outline,
  43. );
  44. },
  45. )
  46. else
  47. Icon(
  48. Icons.cloud_off,
  49. size: 72,
  50. color: colorScheme.outline,
  51. ),
  52. SizedBox(height: screenHeight * 0.025),
  53. Text(
  54. message,
  55. textAlign: TextAlign.center,
  56. style: Theme.of(context).textTheme.titleMedium,
  57. ),
  58. if (onRetry != null) ...[
  59. SizedBox(height: screenHeight * 0.025),
  60. Material(
  61. color: Colors.transparent,
  62. child: InkWell(
  63. onTap: onRetry,
  64. borderRadius: BorderRadius.circular(14),
  65. splashColor: Colors.transparent,
  66. highlightColor: Colors.transparent,
  67. child: Container(
  68. padding: const EdgeInsets.symmetric(
  69. horizontal: 22,
  70. vertical: 12,
  71. ),
  72. decoration: AppSurfaceStyles.card(
  73. context,
  74. backgroundColor: buttonBackground,
  75. radius: 14,
  76. isHighlighted: true,
  77. ),
  78. child: Text(
  79. 'Retry',
  80. style: Theme.of(context).textTheme.titleMedium?.copyWith(
  81. fontWeight: FontWeight.w600,
  82. color: colorScheme.primary,
  83. ),
  84. ),
  85. ),
  86. ),
  87. ),
  88. ],
  89. ],
  90. ),
  91. ),
  92. );
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment