SmartAutoSuggestView<T> class
A widget that shows a TextField and, directly below it in the normal widget tree, an inline suggestion list.
Unlike SmartAutoSuggestBox - which shows suggestions in a floating Overlay - SmartAutoSuggestView embeds both the text field and the list inside the same layout, making it suitable for search screens, filter panels, or any context where you want suggestions to occupy real screen space.
SmartAutoSuggestView<String>(
dataSource: SmartAutoSuggestDataSource(
itemBuilder: (context, value) => SmartAutoSuggestItem(
value: value,
label: value,
),
initialList: (context) => ['apple', 'banana'],
onSearch: (context, current, text) async => await api.search(text),
),
decoration: const InputDecoration(
labelText: 'Search',
border: OutlineInputBorder(),
),
onSelected: (item) => print(item?.label),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- SmartAutoSuggestView
Constructors
-
SmartAutoSuggestView({Key? key, SmartAutoSuggestDataSource<
T> ? dataSource, @Deprecated('Use smartController instead') TextEditingController? controller, SmartAutoSuggestController<T> ? smartController, OnChangeSmartAutoSuggestBox? onChanged, ValueChanged<SmartAutoSuggestItem< ? onSelected, SmartAutoSuggestItemBuilder<T> ?>T> ? itemBuilder, WidgetOrNullBuilder? noResultsFoundBuilder, SmartAutoSuggestSorter<T> ? sorter, TextStyle? style, InputDecoration? decoration, Color? cursorColor, double? cursorHeight, Radius cursorRadius = const Radius.circular(2.0), double cursorWidth = 1.5, bool? showCursor, Brightness? keyboardAppearance, EdgeInsets scrollPadding = const EdgeInsets.all(20.0), BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight, BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight, TextInputAction? textInputAction, FocusNode? focusNode, bool autofocus = false, bool enableKeyboardControls = true, bool enabled = true, List<TextInputFormatter> ? inputFormatters, double listMaxHeight = kSmartAutoSuggestBoxPopupMaxHeight, Widget waitingBuilder(BuildContext context)?, double tileHeight = kComboBoxItemHeight, TextInputType keyboardType = TextInputType.text, int? maxLength, bool showListWhenEmpty = true, SmartAutoSuggestTheme? theme}) -
Creates an inline auto-suggest view.
const
-
SmartAutoSuggestView.form({Key? key, SmartAutoSuggestDataSource<
T> ? dataSource, @Deprecated('Use smartController instead') TextEditingController? controller, SmartAutoSuggestController<T> ? smartController, OnChangeSmartAutoSuggestBox? onChanged, ValueChanged<SmartAutoSuggestItem< ? onSelected, SmartAutoSuggestItemBuilder<T> ?>T> ? itemBuilder, WidgetOrNullBuilder? noResultsFoundBuilder, SmartAutoSuggestSorter<T> ? sorter, TextStyle? style, InputDecoration? decoration, Color? cursorColor, double? cursorHeight, Radius cursorRadius = const Radius.circular(2.0), double cursorWidth = 1.5, bool? showCursor, Brightness? keyboardAppearance, EdgeInsets scrollPadding = const EdgeInsets.all(20.0), BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight, BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight, FormFieldValidator<String> ? validator, AutovalidateMode autovalidateMode = AutovalidateMode.disabled, TextInputAction? textInputAction, FocusNode? focusNode, bool autofocus = false, bool enableKeyboardControls = true, bool enabled = true, List<TextInputFormatter> ? inputFormatters, double listMaxHeight = kSmartAutoSuggestBoxPopupMaxHeight, Widget waitingBuilder(BuildContext context)?, double tileHeight = kComboBoxItemHeight, TextInputType keyboardType = TextInputType.text, int? maxLength, bool showListWhenEmpty = true, SmartAutoSuggestTheme? theme}) -
Creates an inline auto-suggest view with form validation support.
const
Properties
- autofocus → bool
-
Whether this text field should focus itself if nothing else is already
focused.
final
- autovalidateMode → AutovalidateMode
-
Auto-validate mode (only used in SmartAutoSuggestView.form).
final
- controller → TextEditingController?
-
Controls the text being edited.
final
- cursorColor → Color?
-
The color of the cursor.
final
- cursorHeight → double?
-
How tall the cursor will be.
final
- cursorRadius → Radius
-
How rounded the corners of the cursor should be.
final
- cursorWidth → double
-
How thick the cursor will be.
final
-
dataSource
→ SmartAutoSuggestDataSource<
T> ? -
The data source for providing items and async search.
final
- decoration → InputDecoration?
-
Controls the InputDecoration of the text field.
final
- enabled → bool
-
Whether the text field is enabled.
final
- enableKeyboardControls → bool
-
Whether keyboard navigation (arrow keys, Enter, Escape) is enabled.
final
- focusNode → FocusNode?
-
Focus node for the text field.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
inputFormatters
→ List<
TextInputFormatter> ? -
Optional input validation and formatting overrides.
final
-
itemBuilder
→ SmartAutoSuggestItemBuilder<
T> ? -
Custom item widget builder. Falls back to the default tile.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardAppearance → Brightness?
-
The appearance of the keyboard (iOS only).
final
- keyboardType → TextInputType
-
Keyboard type. Defaults to TextInputType.text.
final
- listMaxHeight → double
-
Maximum height of the inline suggestion list. Defaults to 380px.
final
- maxLength → int?
-
Maximum number of characters in the text field.
final
- noResultsFoundBuilder → WidgetOrNullBuilder?
-
Widget shown when no results match the current query.
final
- onChanged → OnChangeSmartAutoSuggestBox?
-
Called when the text changes.
final
-
onSelected
→ ValueChanged<
SmartAutoSuggestItem< ?T> ?> -
Called when the user selects a suggestion.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollPadding → EdgeInsets
-
Configures the padding for the edges surrounding a Scrollable when the
text field scrolls into view.
final
- selectionHeightStyle → BoxHeightStyle
-
Controls how tall the selection highlight boxes are computed to be.
final
- selectionWidthStyle → BoxWidthStyle
-
Controls how wide the selection highlight boxes are computed to be.
final
- showCursor → bool?
-
Whether to show cursor.
final
- showListWhenEmpty → bool
-
Whether to show the list when the text field is empty.
final
-
smartController
→ SmartAutoSuggestController<
T> ? -
A unified controller that provides access to both the text input and the
currently selected item.
final
-
sorter
→ SmartAutoSuggestSorter<
T> ? -
Custom sorter/filter. Defaults to case-insensitive label contains-match.
final
- style → TextStyle?
-
The style to use for the text being edited.
final
- textInputAction → TextInputAction?
-
The type of action button to use for the keyboard.
final
- theme → SmartAutoSuggestTheme?
-
Optional theme override for this widget.
final
- tileHeight → double
-
Height of each suggestion tile. Defaults to kComboBoxItemHeight (50px).
final
-
validator
→ FormFieldValidator<
String> ? -
Validation callback (only used in SmartAutoSuggestView.form).
final
- waitingBuilder → Widget Function(BuildContext context)?
-
Custom loading UI shown while SmartAutoSuggestDataSource.onSearch runs.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< SmartAutoSuggestView< T> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
defaultItemSorter(
String text, Set< SmartAutoSuggestItem< items) → Set<T> >SmartAutoSuggestItem< T> > - Default item sorter: case-insensitive label contains-match.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited