TextPromptSync class

TextPromptSync – Sync text input prompt with validation.

Features:

  • Static cursor (always visible, no blink)
  • TextInputBuffer management
  • Validation with error messages
  • Optional password masking

Usage:

final result = TextPromptSync(
  title: 'Enter name',
  placeholder: 'Your name...',
  validator: (text) => text.length < 2 ? 'Too short' : null,
).run();

Constructors

TextPromptSync({required String title, PromptTheme theme = PromptTheme.dark, String? placeholder, String? validator(String text)?, bool required = false, bool masked = false, String maskChar = '•', bool allowReveal = true})
const

Properties

allowReveal bool
Whether to allow Ctrl+R to toggle visibility in password mode.
final
hashCode int
The hash code for this object.
no setterinherited
maskChar String
Mask character for password mode.
final
masked bool
Whether to mask input (password mode).
final
placeholder String?
Placeholder text shown when empty.
final
required bool
Whether input is required (non-empty).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
theme PromptTheme
Theme for styling.
final
title String
Title displayed in the frame header.
final
validator String? Function(String text)?
Validator function. Return null if valid, or an error message if not. Returning '' is also accepted as success for backwards compatibility.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run() String?
Runs the prompt and returns the result.
toString() String
A string representation of this object.
inherited

Operators

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