TextInputModel class

Text input model for single-line or multi-line text entry.

Features:

  • Character and word navigation
  • Delete operations (character, word, line)
  • Echo modes (normal, password, none)
  • Suggestions/autocomplete
  • Horizontal scrolling for long text (single-line mode)
  • Soft-wrap with vertical scrolling (multi-line mode)
  • Line navigation with up/down arrows (multi-line mode)
  • Click-to-position cursor in multi-line mode
  • Validation

Example:

final input = TextInputModel(
  prompt: 'Name: ',
  placeholder: 'Enter your name',
);

// Multi-line input
final editor = TextInputModel(
  multiline: true,
  width: 60,
  maxHeight: 10,
  prompt: '',
);
Inheritance

Constructors

TextInputModel({String prompt = '> ', String placeholder = '', EchoMode echoMode = EchoMode.normal, String echoCharacter = '*', int charLimit = 0, int width = 0, bool multiline = false, int maxHeight = 0, bool showSuggestions = false, bool useVirtualCursor = true, bool collapseLargePaste = false, int collapsedPasteMinChars = 1200, int collapsedPasteMinLines = 20, TextInputKeyMap? keyMap, CursorModel? cursor, ValidateFunc? validate, TextInputStyles? styles, DateTime nowProvider()?})
Creates a new text input model.

Properties

availableSuggestions → List<String>
Gets available suggestions.
no setter
canRedo → bool
Whether there is an undone edit available to redo.
no setter
canUndo → bool
Whether there is an edit available to undo.
no setter
charLimit ↔ int
Maximum characters allowed (0 = unlimited).
getter/setter pair
collapsedPasteMinChars ↔ int
Minimum paste payload size in characters to trigger collapsing.
getter/setter pair
collapsedPasteMinLines ↔ int
Minimum paste payload size in lines to trigger collapsing.
getter/setter pair
collapseLargePaste ↔ bool
Whether very large paste payloads should be collapsed into a reference token (e.g. [Pasted ~37 lines]) instead of inserting full text.
getter/setter pair
currentSuggestion → String
Gets current suggestion.
no setter
currentSuggestionIndex → int
Gets current suggestion index.
no setter
cursor ↔ CursorModel
Cursor model.
getter/setter pair
document → TextDocument
no setter
echoCharacter ↔ String
Character to show in password mode.
getter/setter pair
echoMode ↔ EchoMode
Echo mode for displaying text.
getter/setter pair
editorState → EditorState
no setter
error ↔ String?
Current validation error.
getter/setter pair
focused → bool
Whether the input is focused.
no setter
hashCode → int
The hash code for this object.
no setterinherited
keyMap ↔ TextInputKeyMap
Key bindings.
getter/setter pair
lastPasteRef → String?
Returns the most recent paste reference URI (e.g. paste://12).
no setter
lineCount → int
Returns the total number of wrapped lines.
no setter
matchedSuggestions → List<String>
Gets matched suggestions.
no setter
maxHeight ↔ int
Maximum visible height in rows (0 = unlimited growth).
getter/setter pair
multiline ↔ bool
Whether to enable multi-line editing.
getter/setter pair
pasteBuffer → Map<String, String>
Returns an unmodifiable view of collapsed paste payloads by URI.
no setter
placeholder ↔ String
Placeholder text when empty.
getter/setter pair
position ↔ int
Gets the cursor position.
getter/setter pair
prompt ↔ String
Prompt displayed before input.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectionEnd ↔ int?
getter/setter pair
selectionStart ↔ int?
getter/setter pair
showSuggestions ↔ bool
Whether to show suggestions.
getter/setter pair
styles ↔ TextInputStyles
Styles for the text input.
getter/setter pair
suggestions ← List<String>
Sets available suggestions for autocomplete.
no getter
terminalCursor → Cursor?
Returns a Cursor for rendering a real cursor in a TUI program. This requires that useVirtualCursor is set to false.
no setter
textView → TextView
no setter
useVirtualCursor ↔ bool
Whether to use a virtual cursor. If false, use terminalCursor to return a real cursor for rendering.
getter/setter pair
validate ↔ ValidateFunc?
Validation function.
getter/setter pair
value ↔ String
Gets the current value as a string.
getter/setter pair
width ↔ int
Display width for horizontal scrolling (0 = unlimited).
getter/setter pair

Methods

activeStyle() → TextInputStyleState
Returns the appropriate style state based on focus.
blur() → void
Blur (unfocus) the input.
clearHistory() → void
Clears all undo and redo history.
cursorEnd() → void
Move cursor to end.
cursorStart() → void
Move cursor to start.
deleteBackward({bool word = false, bool coalesce = false}) → bool
Deletes backward from the cursor or removes the current selection.
deleteForward({bool word = false, bool coalesce = false}) → bool
Deletes forward from the cursor or removes the current selection.
deleteSelection() → bool
Deletes the current selection, returning whether anything changed.
focus() → Cmd?
Focus the input.
getSelectedText() → String
Returns the currently selected text.
init() → Cmd?
Returns an optional command to execute on program startup.
override
insertText(String text, {bool replaceSelection = true, bool coalesce = false}) → void
Inserts text at the cursor, optionally replacing the current selection.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pushHistoryBoundary() → void
Breaks the current undo coalescing chain.
redo() → bool
Reapplies the most recently undone edit state.
replaceSelection(String text) → void
Replaces the current selection, or inserts at the cursor if collapsed.
reset() → void
Reset the input to empty.
selectAll() → void
Selects all text in the input.
setText(String s, {bool recordHistory = true}) → void
Replaces the current text and collapses the selection at the end.
setTextState({required String text, required int selectionBase, required int selectionExtent, bool recordHistory = true}) → void
Replaces the current text and selection state.
setValue(String s) → void
Sets the value of the text input (method form for API compatibility).
toString() → String
A string representation of this object.
inherited
undo() → bool
Restores the most recent previous edit state.
update(Msg msg) → (TextInputModel, Cmd?)
Updates the component state in response to a message.
override
view() → Object
Renders the current model state for display.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited