auto_suggest_box 0.1.2
auto_suggest_box: ^0.1.2 copied to clipboard
A highly customizable, performance-optimized auto-suggest/autocomplete widget for Flutter with Fluent UI design. Features debounced search, LRU caching, keyboard navigation, form validation, advanced [...]
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.1.0 - 2024-12-23 #
Added #
Core Widget - FluentAutoSuggestBox
FluentAutoSuggestBox<T>- Main autocomplete widget with generic type supportFluentAutoSuggestBox.form()- Form-enabled constructor with validation support- Debounced search with configurable delay (default: 300ms)
- Minimum search length requirement to prevent unnecessary searches
- Custom item builders for full control over suggestion rendering
- Custom sorter function for controlling match logic
- Loading and error state builders
- Overlay direction control (above/below)
- Clear button toggle
- Keyboard type and input formatters support
State Management - AutoSuggestController
AutoSuggestController<T>- Centralized state management- Debounce timer management
- Loading/error state tracking
- Overlay visibility control
- Recent searches history with configurable limit
- Search metrics and statistics (success rate, total searches)
getStats()method for performance monitoring- Proper disposal and cleanup
Caching System - SearchResultsCache
SearchResultsCache<T>- LRU cache implementation- Time-To-Live (TTL) expiration for cached entries
- Automatic LRU eviction when cache is full
- Prefix matching for better cache hit rates
- Cache statistics (hit rate, size, evictions)
CacheStatsclass for detailed metrics
Item Model - FluentAutoSuggestBoxItem
- Generic type support for any data model
- Label and custom child widget support
- Subtitle widget for additional information
- Selection state tracking
- Focus change callbacks
- Semantic labels for accessibility
- Enabled/disabled state
Overlay System - AutoSuggestOverlay
- Smooth overlay positioning with CompositedTransformFollower
- Race condition prevention for async searches
- Automatic scroll to selected item
- Loading indicator during server search
- Empty state with helpful message
- Bidirectional display support
Keyboard Navigation
- Arrow Up/Down for item selection
- Enter to confirm selection
- Escape to close overlay
- Tab/Shift+Tab for focus navigation
- Keyboard shortcuts for advanced search
Advanced Search Dialog
AdvancedSearchDialog<T>- Full-featured search dialogAdvancedSearchDialog.show()- Single selection modeAdvancedSearchDialog.showMultiSelect()- Multi-selection mode- Three view modes: List, Grid, Compact
- Custom filter builder support
- Search statistics display
- Pagination support
- Custom animations with configurable duration and curves
- Keyboard shortcut trigger (default: F3)
Configuration Classes
AdvancedSearchConfig- Main dialog configurationAdvancedSearchTheme- Visual theming (colors, spacing, radius)AdvancedSearchIcons- Icon customizationAdvancedSearchLayout- Layout dimensionsAdvancedSearchAnimation- Animation settings
Common Utilities
FluentTextField- Fluent-styled text field wrapperFluentTextFormField- Form field with validation supportValidatorFormField- Custom form field with error display
Performance Optimizations
- Reduced widget rebuilds (only when necessary)
- Efficient memory usage with proper disposal
- Smart caching with prefix matching
- Debouncing to minimize API calls
- Race condition prevention for async operations
Accessibility
- Semantic labels throughout
- Screen reader support
- Proper focus management
- ARIA-like attributes
BLoC/Cubit State Management
FluentAutoSuggestBoxCubit<T>- Cubit for managing FluentAutoSuggestBox stateFluentAutoSuggestBoxState<T>- State class with:items- List of suggestion itemsselectedItem- Currently selected itemtext- Current input textisLoading- Loading stateerror- Error objectisEnabled/isReadOnly- Widget state
- Item management methods:
setItems,addItem,addItems,removeItem,clearItems - Selection methods:
selectItem,selectByValue,selectByIndex,clearSelection - State methods:
setLoading,setError,clearError,setEnabled,setReadOnly - Helper methods:
reset,clear,search,getItemAt,getItemByValue
Dependencies #
- fluent_ui: ^4.13.0 - Fluent UI design system
- flutter_bloc: ^8.1.6 - BLoC state management
- equatable: ^2.0.5 - Value equality for states
- gap: ^3.0.1 - Spacing utilities
Future Releases #
0.2.0 Planned #
Planned Features
- Pagination support for large datasets
- RTL language improvements
- Voice search support
- Grouped suggestions
- Inline suggestions (ghost text)