Skip to content

CompletionTextInput

A TextInput with an anchored completion menu.

See also: Autocomplete when the result is one picked option.

Learn more: Forms & validation

Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.

CompletionTextInput(
placeholder: 'Type a command…',
showOnEmptyQuery: true,
provider: (request) {
const options = <TextCompletionOption>[
TextCompletionOption(label: 'benchmark'),
TextCompletionOption(label: 'storybook'),
TextCompletionOption(label: 'command-palette'),
TextCompletionOption(label: 'semantic-tree'),
];
final q = request.query.toLowerCase();
return options.where((o) => o.label.toLowerCase().contains(q));
},
)

The field uses core TextCompletionController semantics for option state and acceptance. This widget supplies provider-driven options plus the floating menu UI; TextInput still owns editing, Tab acceptance, Escape dismissal, and Up/Down completion navigation. Clicking a completion also accepts it; Enter submits the text rather than accepting.

ParameterTypeDefaultDescription
provider:TextCompletionProviderrequiredProduces completion options for the current request.
requestBuilder:TextCompletionRequestBuilderdefaultTextCompletionRequestBuilds the completion range and query from the current text value.
controller:TextEditingController?—Text editing controller for the underlying input.
completionController:TextCompletionController?—External completion state controller. If omitted, this widget owns one.
historyController:TextHistoryController?—Optional command-history controller shared with the input.
focusNode:FocusNode?—Focus node used by the underlying text input.
autofocus:boolfalseWhether the field should request focus when mounted.
onChanged:void Function(String text)?—Called after user and semantic edits. Programmatic controller writes notify controller listeners instead. See TextInput.onChanged.
onSubmit:void Function(String text)?—Called when the user submits the current text.
onEscape:void Function()?—Called when Escape is pressed and the completion menu does not consume it.
onCompletionAccepted:void Function(TextCompletionOption option)?—Called after a completion option is accepted into the input.
placeholder:String''Placeholder text shown when the input is empty.
placeholderStyle:CellStyleconst CellStyle(dim: true)Style used for placeholder.
style:CellStyleCellStyle.noneEntered-text base styling, plus optional hover, focus, disabled, and invalid state entries from CellStyle.interactive.
cursorStyle:CellStyleconst CellStyle(inverse: true)Style applied to the cursor cell.
blinkInterval:Durationconst Duration(milliseconds: 500)Cursor blink period.
enableBlink:booltrueWhether cursor blinking is enabled.
enabled:booltrueWhether editing, completion, and focus behavior are enabled.
readOnly:boolfalseWhether the field can receive focus but not edit text.
validationError:String?—Marks the current value invalid: the field draws in the theme’s error style and reports this message through semantics, but doesn’t show the text. Inside a FormField, this message wins over the FormField’s validator, though not over its own error, and the FormField shows the winning message below the input.
semanticLabel:String?—Label exposed through the underlying text-field semantic node. More
semanticState:SemanticStateSemanticState.emptyExtra semantic state merged into the underlying text-field node.
clipboardPolicy:TextClipboardPolicy?—Clipboard write/read policy for input copy and paste.
pastePolicy:TextPastePolicyconst TextPastePolicy()Paste normalization and size policy for inserted text.
commitHistoryOnSubmit:booltrueWhether submitted text is added to historyController.
showOnEmptyQuery:boolfalseWhether to show completions even when the current query is empty.
maxVisible:int6Maximum number of completion rows visible in the overlay.
  • semanticLabel: When omitted, placeholder is used when non-empty.

CompletionTextInput is defined in packages/fleury/lib/src/catalog/completion_text_input.dart.

Category: Inputs & controls · All widgets