TEmptyState.search constructor

TEmptyState.search({
  1. Key? key,
  2. String? query,
  3. String? title,
  4. String? description,
  5. VoidCallback? onClear,
  6. Widget? action,
  7. bool compact = false,
  8. EdgeInsetsGeometry padding = const EdgeInsets.all(32.0),
})

Creates a search results empty state placeholder.

Implementation

factory TEmptyState.search({
  Key? key,
  String? query,
  String? title,
  String? description,
  VoidCallback? onClear,
  Widget? action,
  bool compact = false,
  EdgeInsetsGeometry padding = const EdgeInsets.all(32.0),
}) {
  final effectiveTitle = title ?? (query != null && query.isNotEmpty ? 'No results for "$query"' : 'No matching results');
  final effectiveDesc = description ?? 'Try checking for spelling errors or adjusting your search filters.';

  final effectiveAction = action ??
      (onClear != null
          ? TButton(
              text: 'Clear Search',
              icon: Icons.clear_rounded,
              type: TButtonType.tonal,
              size: TButtonSize.xs,
              onPressed: (_) => onClear(),
            )
          : null);

  return TEmptyState(
    key: key,
    icon: Icons.search_off_rounded,
    title: effectiveTitle,
    description: effectiveDesc,
    action: effectiveAction,
    compact: compact,
    padding: padding,
  );
}