smart_auto_suggest_box 0.13.1
smart_auto_suggest_box: ^0.13.1 copied to clipboard
A highly customizable auto-suggest text field with smart dropdown positioning that adapts to available screen space.
ChangeLog #
0.13.1 #
Bug Fixes #
-
Fixed async search side-effects during build — triggering
onSearchwhen no local results were found is now scheduled after the current frame instead of being invoked from inside widgetbuild(). This fixessetState() or markNeedsBuild() called during buildinSmartAutoSuggestBox,SmartAutoSuggestView, andSmartAutoSuggestMultiSelectBox. -
Fixed auto-scroll on unattached
ScrollController— keyboard focus scrolling now waits until the list is attached before callinganimateTo, preventingScrollController not attached to any scroll views.
0.13.0 #
New Features #
-
Error state in overlay — when
onSearchthrows an exception, the overlay now displays a localized error message with an error icon instead of silently swallowing the error. The error is automatically cleared when a new search starts. -
errorMessageonSmartAutoSuggestDataSource— newValueNotifier<String?>that holds the error message from the last failed search. Listen to it to observe error state externally. -
errorSubtitleStyleanderrorIconColoronSmartAutoSuggestTheme— new theme properties for customizing the error card appearance. -
searchError/searchErrorHintlocalizations — new localized strings for the error state across all 13 supported languages.
0.12.0 #
Bug Fixes #
-
Fixed double
onFocusChangecallback —item.selectedsetter already callsonFocusChange, but the code was also calling it explicitly, resulting in duplicate callbacks. Removed the redundant calls across all three widgets. -
Fixed stale selection on items leaving
filteredItems—_unselectAll()now iteratesdataSource.items(all items) instead of onlyfilteredItems, so items that move out of the filtered set have theirselectedflag properly cleared.
Improvements #
-
Auto-focus first item on data change — when
filteredItemsupdates (e.g. async search completes), the first item is now automatically focused on desktop, so the user can immediately navigate with arrow keys. -
_autoSelectFirstItemadded toSmartAutoSuggestView— the inline list widget now auto-selects the first item on desktop platforms, matching the behavior ofSmartAutoSuggestBoxandSmartAutoSuggestMultiSelectBox. -
_selectItem()extracted frombuild()— the item selection logic is now a proper state method instead of a closure recreated on every build, in all three widgets. -
isDesktopPlatformhelper — new top-level getter in the common library replaces repeatedswitch (defaultTargetPlatform)blocks across widgets.
0.11.0 #
Breaking Changes #
SmartAutoSuggestDataSourceis now stateful — the constructor is no longerconst. If you stored aconst SmartAutoSuggestDataSource(...), remove theconstkeyword. All existing usage patterns (inline construction inbuild) continue to work without changes thanks to the newhasSameConfig()check.
Features #
-
Stateful
SmartAutoSuggestDataSource— the data source now owns and manages overlay state internally:items(ValueNotifier<Set<SmartAutoSuggestItem<T>>>) — all available items (unfiltered).filteredItems(ValueNotifier<Set<SmartAutoSuggestItem<T>>>) — the currently filtered/sorted items shown in the overlay.isLoading(ValueNotifier<bool>) — whether an async search is in progress.
-
External control — you can now observe and manipulate the data source from outside the widget:
filter(searchText, [sorter])— apply sorter and updatefilteredItems.search(context, searchText)— trigger an async search programmatically.setItems(newItems, searchText)— replace all items and re-filter.addItems(newItems, searchText)— merge new items and re-filter.resetSearchState()— reset the last query so the same search can run again.- Listen to
dataSource.filteredItemsanddataSource.isLoadingfor real-time state updates.
-
Immediate overlay updates — the overlay now listens directly to
dataSource.filteredItemsanddataSource.isLoading, so tiles update instantly when an async search completes (no manual refresh needed). -
hasSameConfig()— prevents unnecessary re-initialization when theSmartAutoSuggestDataSourceis recreated inline inbuildmethods with the same callbacks and settings.
Internal #
- Removed internal
StreamControllerfor items in all three widgets (SmartAutoSuggestBox,SmartAutoSuggestView,SmartAutoSuggestMultiSelectBox). - Overlay build methods simplified from nested
ValueListenableBuilderto directDataSourcereads.
0.10.1 #
Features #
- Desktop keyboard auto-focus — on desktop platforms (Windows, macOS, Linux) the first item in the floating overlay is now automatically focused when the dropdown opens, so the user can immediately navigate with arrow keys and confirm with Enter without needing to press ↓ first.
- Enter key support in
SmartAutoSuggestBox— pressing Enter now selects the currently focused item (was already supported inSmartAutoSuggestMultiSelectBoxandSmartAutoSuggestView). - Focus follows filter — when the user types and the suggestion list updates, focus automatically resets to the first matching item on desktop.
Example #
- Added dedicated Multi-Select demo screen with 6 examples: basic usage,
max selections, custom
maxVisibleChips, customchipBuilder, controller demo, and async search. Accessible via a new "Multi-Select" tab in the bottom navigation bar.
0.10.0 #
Features #
-
SmartAutoSuggestMultiSelectBox— new multi-select widget that allows selecting multiple items from a floating suggestion overlay.- Selected items are shown as compact chips below the text field.
- Configurable
maxVisibleChips(default 3) — excess items are accessible via a "Show all" button that opens aBottomSheet. - Each chip has a cancel button to deselect the item.
- Optional
maxSelections— when the limit is reached, remaining unselected items are disabled in the overlay. - Tapping a selected item in the overlay toggles it off (deselects).
- Custom
chipBuilderfor full control over chip appearance.
-
SmartAutoSuggestMultiSelectController— new controller that provides access to both the text input (textController) and the set of currently selected items (selectedItemsValueNotifier). Supportsselect,deselect,toggleSelection,clearAll, andisSelected. -
SmartAutoSuggestBoxOverlayTile.trailing— new optional widget displayed at the end of overlay tiles (used internally for check marks in multi-select mode).
Example #
- Added "Multi-Select (Basic)" and "Multi-Select (Max 5)" demo sections in Advanced Examples.
0.7.3 #
Bug Fixes #
- Keep focus when interacting with overlay — the floating suggestion
list is now treated as part of the text field using
TextFieldTapRegion, so tapping overlay items no longer causes the text field to lose focus. Focus is only removed when tapping truly outside both the text field and the overlay.
0.7.2 #
Features #
- Show all items on focus — when the input field is focused with empty content, all available items are now displayed in the suggestion list.
- Cursor-based search text — the search query is now calculated from the start of the text to the cursor position, not the entire text. For example, if the text is "الحساب الجديد" and the cursor is after "الحساب", only "الحساب" is used as the search query.
0.7.1 #
Bug Fixes #
- Dismiss overlay on selection — the floating suggestion overlay now correctly closes when the user selects an item.
- Dismiss overlay on tap outside — tapping outside the overlay or the text field now dismisses the floating suggestion list and unfocuses the input.
- Builder items selectable — items using
SmartAutoSuggestItem.builderare now tappable to trigger selection (both inSmartAutoSuggestBoxandSmartAutoSuggestView).
0.7.0 #
Features #
SmartAutoSuggestHighlightText— new widget that highlights the matching portion of suggestion labels in bold with the theme's primary color. Automatically used in default tiles when no custom builder is provided.SmartAutoSuggestItem.key— optional unique key for item identity. When provided, equality and hashing usekeyinstead ofvalue.SmartAutoSuggestItem.builder— new builder callbackWidget Function(BuildContext context, String searchText)?that replaces the deprecatedchild. The returned widget is automatically wrapped in aFocuswidget for keyboard navigation support. ThesearchTextparameter enables custom highlight rendering.
Deprecations #
SmartAutoSuggestItem.childis deprecated — usebuilderinstead.
Example #
- Added "Highlight + Item Builder" demo section showing highlighted text
and the
builderAPI withFocuswrapping.
0.6.0 #
Features #
-
SmartAutoSuggestController<T>— new unified controller that wraps:textController(TextEditingController) — for text inputselectedItem(ValueNotifier<SmartAutoSuggestItem<T>?>) — for observing the currently selected itemselect(item)— sets the selected item and updates the text fieldclearSelection()— clears both selection and textdispose()— releases resources
-
Both
SmartAutoSuggestBoxandSmartAutoSuggestViewaccept an optionalsmartControllerparameter.
Deprecations #
controller(TextEditingController?) parameter is deprecated on both widgets — usesmartControllerinstead.
Example #
- Added "SmartAutoSuggestController" demo section showing how to observe selection state and clear it programmatically.
0.5.0 #
Features #
selectedItemBuilder— new optional callback onSmartAutoSuggestBoxthat displays a custom widget (e.g. aChip, card, or avatar row) after the user selects an item, replacing theTextField.- Tapping the custom widget dismisses it and restores the
TextFieldfor a new search. - Use
SmartAutoSuggestBoxState.clearSelection()to clear it programmatically. - When
null(the default), the classic behavior is preserved — the selected item's label is placed into theTextFieldas plain text.
- Tapping the custom widget dismisses it and restores the
Example #
- Added "Selected Item Builder" demo section in the Box demo tab showing a
Chipwidget after selection.
0.4.0 #
Features #
SmartAutoSuggestTheme— newThemeExtensionfor customizing the appearance of bothSmartAutoSuggestBoxandSmartAutoSuggestView.- Provides granular control over overlay colors, shadows, border radius, tile colors, text styles, progress indicator, divider indent, and more.
- Factory constructors
SmartAutoSuggestTheme.light()andSmartAutoSuggestTheme.dark()with sensible defaults. - Can be supplied via
ThemeData.extensionsor passed directly to a widget.
- Both
SmartAutoSuggestBoxandSmartAutoSuggestViewnow accept an optionalSmartAutoSuggestTheme? themeparameter to override the theme locally.
Example #
- Split example app into multiple files:
main.dart,data.dart,box_demo.dart,view_demo.dart,advanced_examples.dart. - Example now registers
SmartAutoSuggestTheme.light()andSmartAutoSuggestTheme.dark()viaThemeData.extensions.
0.3.0 #
Breaking Changes #
-
SmartAutoSuggestDataSourceAPI overhaul — the data source now works with raw values (T) instead ofSmartAutoSuggestItem<T>:Property Old type New type initialListList<SmartAutoSuggestItem<T>> Function(BuildContext)?List<T> Function(BuildContext)?onSearchFuture<List<SmartAutoSuggestItem<T>>> Function(BuildContext, List<SmartAutoSuggestItem<T>>, String?)?Future<List<T>> Function(BuildContext, List<T>, String?)? -
New required
itemBuilder—SmartAutoSuggestDataSourcenow requires anitemBuildercallback that converts each raw valueTinto aSmartAutoSuggestItem<T>:SmartAutoSuggestDataSource<String>( itemBuilder: (context, value) => SmartAutoSuggestItem( value: value, label: value[0].toUpperCase() + value.substring(1), ), initialList: (context) => ['apple', 'banana'], )
Example #
- Updated all example code to use the new
itemBuilderAPI.
0.2.1 #
Fixes #
- Keyboard-aware overlay sizing (
SmartAutoSuggestBox): popup placement/height now accounts for keyboard insets (MediaQuery.viewInsets.bottom) instead of relying on safe padding only. - Direction priority + best-space fallback: the preferred direction is tried first; if it cannot fit the popup target size, the overlay falls back to the direction with the largest available space.
- Auto-scroll for constrained layouts: when all directions are constrained, the nearest scrollable parent is auto-scrolled to improve available space, then the overlay is recomputed.
- Overlay reacts to keyboard metric changes: overlay now rebuilds when keyboard opens/closes to keep placement accurate.
- Added/updated widget tests covering keyboard-aware placement, fallback behavior, and auto-scroll behavior.
0.2.0 #
Features #
-
SmartAutoSuggestView: New inline widget that shows aTextFieldwith a suggestion list rendered directly below it in the normal widget tree — no floating overlay. Ideal for search screens, filter panels, and embedded search UIs. Shares the sameSmartAutoSuggestDataSourceAPI asSmartAutoSuggestBox. -
Scrollbar: Both
SmartAutoSuggestBoxandSmartAutoSuggestViewnow show a visible scrollbar thumb when the suggestion list overflows.listMaxHeight: maximum height of the inline suggestion list (default 380px).showListWhenEmpty: whether to display the list when the text field is empty (defaulttrue).- Supports
.formconstructor withvalidatorandautovalidateMode. - Full keyboard navigation (↑ ↓ Enter).
-
Shared-type rename — types that are shared between
SmartAutoSuggestBoxandSmartAutoSuggestViewhave been renamed to drop theBoxinfix:Old name New name SmartAutoSuggestBoxItemSmartAutoSuggestItemSmartAutoSuggestBoxDataSourceSmartAutoSuggestDataSourceSmartAutoSuggestBoxSearchModeSmartAutoSuggestSearchModeSmartAutoSuggestBoxSorterSmartAutoSuggestSorterSmartAutoSuggestBoxItemBuilderSmartAutoSuggestItemBuilder
Deprecations #
- All five old names above are kept as deprecated
typedefaliases for full backward compatibility — no code changes required to migrate.
Example #
- Updated example app with a bottom
NavigationBarswitching betweenSmartAutoSuggestBox(floating overlay),SmartAutoSuggestView(inline list), and Advanced Examples demos. - Updated all example code to use the new type names.
- BottomSheet example:
SmartAutoSuggestViewinside ashowModalBottomSheet. - Custom no-results: Rich custom widget with icon, message, and action button.
- Custom item builder: Tiles with leading emoji avatar, subtitle, and trailing badge.
- Custom loading: Shimmer-style placeholder while server search is in progress.
0.1.0 #
Features #
SmartAutoSuggestDataSource(wasSmartAutoSuggestBoxDataSource): New data source abstraction.initialList: Synchronous callback to provide initial items with access toBuildContext.onSearch: Async search callback that receives(context, currentItems, searchText).searchMode: Controls whenonSearchis invoked —onNoLocalResults(default) oralways.debounce: Configurable debounce duration (default: 400ms).
SmartAutoSuggestSearchMode(wasSmartAutoSuggestBoxSearchMode): Enum to control search behavior.
Deprecations #
itemsconstructor parameter — usedataSourcewithinitialListinstead.onNoResultsFound— usedataSourcewithonSearchinstead.
Features #
SmartAutoSuggestBoxDataSource: New data source abstraction that replaces theitemsandonNoResultsFoundparameters with a cleaner, unified API.initialList: Synchronous callback to provide initial items with access toBuildContext.onSearch: Async search callback that receives(context, currentItems, searchText).searchMode: Controls whenonSearchis invoked —onNoLocalResults(default) oralways.debounce: Configurable debounce duration (default: 400ms).
SmartAutoSuggestBoxSearchMode: New enum to control search behavior:onNoLocalResults: Only callsonSearchwhen local filtering yields no results.always: CallsonSearchon every text change after debounce.
Deprecations #
itemsconstructor parameter — usedataSourcewithinitialListinstead.onNoResultsFound— usedataSourcewithonSearchinstead.
Example #
- Updated example app with 4 demos:
initialList,onSearch,searchMode.always, and deprecateditemsbackward compatibility.
0.0.2 #
Features #
- Smart dropdown positioning: The dropdown now supports 4 directions:
top,bottom,start, andend. - Auto-fallback positioning: When there isn't enough space in the preferred direction, the dropdown automatically repositions to the opposite direction.
- RTL support:
startandenddirections respect the text directionality (ltr/rtl).
Breaking Changes #
SmartAutoSuggestBoxDirection.belowis now deprecated.- Use
SmartAutoSuggestBoxDirection.bottominstead. SmartAutoSuggestBoxDirection.aboveis now deprecated.- Use
SmartAutoSuggestBoxDirection.topinstead.
Example #
- Updated example app to demonstrate all 4 dropdown directions with interactive direction switching.
0.0.1 #
- Initial release of
smart_auto_suggest_box.