compact static method

Widget compact({
  1. required BuildContext context,
  2. required Exception error,
  3. required VoidCallback onRetry,
  4. String? message,
  5. Color? backgroundColor,
  6. Color? textColor,
})

Creates a compact error widget for inline errors (like load more errors)

Best suited for bottom loading errors where space is limited

Implementation

static Widget compact({
  required BuildContext context,
  required Exception error,
  required VoidCallback onRetry,
  String? message,
  Color? backgroundColor,
  Color? textColor,
}) {
  return Container(
    margin: const EdgeInsets.all(16.0),
    padding: const EdgeInsets.all(16.0),
    decoration: BoxDecoration(
      color: backgroundColor ?? Colors.red[50],
      borderRadius: BorderRadius.circular(8),
      border: Border.all(
        color: Colors.red[200]!,
        width: 1,
      ),
    ),
    child: Row(
      children: [
        Icon(
          Icons.error_outline,
          color: textColor ?? Colors.red[700],
          size: 24,
        ),
        const SizedBox(width: 12),
        Expanded(
          child: Text(
            message ?? 'Failed to load more items',
            style: Theme.of(context).textTheme.bodyMedium?.copyWith(
                  color: textColor ?? Colors.red[700],
                ),
          ),
        ),
        const SizedBox(width: 12),
        TextButton(
          onPressed: onRetry,
          child: Text(
            'Retry',
            style: TextStyle(
              color: textColor ?? Colors.red[700],
              fontWeight: FontWeight.bold,
            ),
          ),
        ),
      ],
    ),
  );
}