TEmptyState.error constructor

TEmptyState.error({
  1. Key? key,
  2. String title = 'Something went wrong',
  3. String description = 'Failed to load data. Please check your connection and try again.',
  4. VoidCallback? onRetry,
  5. Widget? action,
  6. bool compact = false,
  7. EdgeInsetsGeometry padding = const EdgeInsets.all(32.0),
})

Creates an error / failure empty state with an optional retry callback.

Implementation

factory TEmptyState.error({
  Key? key,
  String title = 'Something went wrong',
  String description = 'Failed to load data. Please check your connection and try again.',
  VoidCallback? onRetry,
  Widget? action,
  bool compact = false,
  EdgeInsetsGeometry padding = const EdgeInsets.all(32.0),
}) {
  final effectiveAction = action ??
      (onRetry != null
          ? TButton(
              text: 'Try Again',
              icon: Icons.refresh_rounded,
              type: TButtonType.tonal,
              size: TButtonSize.xs,
              onPressed: (_) => onRetry(),
            )
          : null);

  return TEmptyState(
    key: key,
    icon: Icons.error_outline_rounded,
    iconColor: Colors.redAccent,
    title: title,
    description: description,
    action: effectiveAction,
    compact: compact,
    padding: padding,
  );
}