Tinyrack

Autocomplete

Complete free text from typed static or asynchronous suggestions.

Complete free text from typed static or asynchronous suggestions.

Contract

AxisContract
ValueThe query remains free-form text. Selecting a suggestion also stores its typed value on the controller.
SuggestionsPass static items or load them asynchronously with optionsBuilder. Older asynchronous responses are discarded.
InteractionPointer hover keeps input focus. Arrow keys move the highlight, Enter selects, Escape closes, and Tab moves on without selecting.
Layer sizelayerSize sizes the complete suggestion layer. It matches the field width by default and lets content grow up to TRMeasurements.measureXl high.

Install

Add the package, then import its public library.

flutter pub add tinyrack_ui
import 'package:tinyrack_ui/tinyrack_ui.dart';

Playground

Usage

import 'package:material_ui/material_ui.dart';
import 'package:tinyrack_ui/tinyrack_ui.dart';

TRAutocomplete<String>(
  label: 'Region',
  placeholder: 'Search regions',
  items: const [
    TRAutocompleteItem(value: 'seoul', label: 'Seoul'),
    TRAutocompleteItem(value: 'tokyo', label: 'Tokyo'),
  ],
  onSelected: (region) => selectedRegion = region,
)

Examples

Completion modes permalink

Choose list suggestions, inline completion, both behaviors, or manual mode. Manual mode waits for text before showing an empty-query list.

Asynchronous suggestions permalink

Return a Future from optionsBuilder to load remote suggestions. If requests finish out of order, only the newest query updates the popup.

Sizes and states permalink

Match nearby controls with uiSize and communicate unavailable, read-only, or invalid input through the corresponding field state.

Controller lifecycle permalink

Own a TRAutocompleteController when another control must read the query, clear the field, or inspect the typed selected value. Dispose it with the owning State.

Form validation permalink

TRAutocompleteFormField reports the typed selected value to Form validation and save callbacks while the query remains editable.

Pointer and keyboard permalink

Hover suggestions without moving input focus. Use Arrow keys to highlight, Enter to select, Escape to close, and Tab to leave without selecting.

API

Suggestions

PropType / defaultPurpose
itemsList<TRAutocompleteItem<T>> = const []Provide typed static suggestions. Disabled items are filtered out.
optionsBuilderFutureOr<Iterable<TRAutocompleteItem<T>>> Function(String)?Load suggestions from the current query. It may return synchronously or asynchronously.
completionModeTRAutocompleteCompletionMode = listChoose manual, list, inline, or both completion behavior.
TRAutocompleteItemvalue, label, enabled = true, leading?, trailing?Pair a typed value with its label and optional presentation.

State and callbacks

PropType / defaultPurpose
controllerTRAutocompleteController<T>?Observe query and value, call select or clear, and dispose owned text and focus controllers.
onQueryChangeValueChanged<String>?Report free-text edits.
onSelectedValueChanged<T>?Report the typed value selected from a suggestion.

Field and form

PropType / defaultPurpose
enabled, readOnlybool = true, bool = falseDisable interaction or keep a focusable immutable query.
label, placeholder, helperText, errorTextString?Describe the field and its validation state.
uiSize, widthTRUiSize = md, double?Set the control size and optional fixed field width.
layerSizeTRLayerSize · match anchor / content height ≤ measureXlSizes the complete suggestion layer independently from the field width.
TRAutocompleteFormFieldFormField<T>Participate in validation and save callbacks with a typed selected value.