bloc/bloc library

BLoC/Cubit state management for auto_suggest_box

This module provides Cubit-based state management for FluentAutoSuggestBox.

FluentAutoSuggestBoxCubit (Widget State Management)

Use this cubit to manage the state of FluentAutoSuggestBox widget:

// 1. Create a cubit
final cubit = FluentAutoSuggestBoxCubit<Product>();

// 2. Set items
cubit.setItems([
  FluentAutoSuggestBoxItem(value: product1, label: 'Product 1'),
  FluentAutoSuggestBoxItem(value: product2, label: 'Product 2'),
]);

// 3. Select an item
cubit.selectItem(items.first);

// 4. Clear selection
cubit.clearSelection();

// 5. Use with BlocBuilder
BlocBuilder<FluentAutoSuggestBoxCubit<Product>, FluentAutoSuggestBoxState<Product>>(
  bloc: cubit,
  builder: (context, state) {
    return FluentAutoSuggestBox<Product>(
      items: state.items,
      enabled: state.isEnabled,
      onSelected: (item) => cubit.selectItem(item),
    );
  },
);

AutoSuggestCubit (Search Provider)

Use this cubit for server-side search with caching:

final searchCubit = AutoSuggestCubit<Product>(
  provider: (query, {filters}) async {
    return await api.searchProducts(query);
  },
  config: AutoSuggestConfig(
    debounceDelay: Duration(milliseconds: 300),
    dataAge: Duration(minutes: 15),
  ),
);

Classes

AutoSuggestBlocBuilder<T>
A convenient builder widget for AutoSuggestCubit
AutoSuggestConfig
Configuration for AutoSuggestCubit
AutoSuggestCubit<T>
AutoSuggestCubit - BLoC-based state management for auto-suggest
AutoSuggestEmpty<T>
Empty state when search returns no results
AutoSuggestError<T>
Error state when search fails
AutoSuggestInitial<T>
Initial state before any search is performed
AutoSuggestLoaded<T>
Loaded state with search results
AutoSuggestLoading<T>
Loading state while fetching search results
AutoSuggestState<T>
Base state for AutoSuggestCubit
BlocAutoSuggestBox<T>
A widget that integrates FluentAutoSuggestBox with BLoC pattern
FluentAutoSuggestBoxCubit<T>
Cubit لإدارة حالة FluentAutoSuggestBox
FluentAutoSuggestBoxState<T>
حالة FluentAutoSuggestBox
RetryConfig
Configuration for retry behavior

Typedefs

AutoSuggestProvider<T> = Future<List<T>> Function(String query, {Map<String, dynamic>? filters})
Provider function type for fetching search results
BlocEmptyBuilder = Widget Function(BuildContext context, String query)
Builder for empty state
BlocErrorBuilder<T> = Widget Function(BuildContext context, Object error, String query, VoidCallback onRetry)
Builder for error state
BlocItemBuilder<T> = Widget Function(BuildContext context, T item, bool isSelected, VoidCallback onTap)
Builder for items in the suggestion list
BlocLoadingBuilder = Widget Function(BuildContext context, String query)
Builder for loading state