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})
Creates a new text input model.

Properties

availableSuggestions List<String>
Gets available suggestions.
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
echoCharacter String
Character to show in password mode.
getter/setter pair
echoMode EchoMode
Echo mode for displaying text.
getter/setter pair
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
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.
cursorEnd() → void
Move cursor to end.
cursorStart() → void
Move cursor to start.
focus() Cmd?
Focus the input.
getSelectedText() String
Returns the currently selected text.
init() Cmd?
Returns an optional command to execute on program startup.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Reset the input to empty.
selectAll() → void
Selects all text in the input.
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
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