FormPrompt class
A multi-field text input prompt rendered inside a single FrameView.
Composes existing TextInputBuffer, FrameView, KeyBindings, and PromptRunner to present multiple labeled text fields with per-field validation, optional masking, and cross-field validation.
Key handling:
- Active field receives all typing keys
- Tab / ↓: move to next field
- ↑: move to previous field
- Enter: next field if not on last, submit if on last
- Ctrl+R: toggle reveal on the focused field (if masked + allowReveal)
- Esc / Ctrl+C: cancel (returns
null)
final result = FormPrompt(
title: 'Create Account',
theme: PromptTheme.dark,
fields: [
FormFieldConfig(label: 'Password', masked: true, required: true),
FormFieldConfig(label: 'Verify', masked: true, required: true,
placeholder: 're-enter to confirm'),
],
crossValidator: (values) =>
values[0] != values[1] ? 'Passwords do not match' : null,
).run();
Constructors
-
FormPrompt({required String title, required List<
FormFieldConfig> fields, PromptTheme theme = PromptTheme.dark, String? crossValidator(List<String> values)?}) -
const
Properties
-
crossValidator
→ String? Function(List<
String> values)? -
Optional cross-field validator run on submit.
Return an error message to block submission, or
nullto allow it.final -
fields
→ List<
FormFieldConfig> -
Field configurations, rendered top-to-bottom.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- theme → PromptTheme
-
Theme for styling.
final
- title → String
-
Title shown in the frame header.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run(
) → FormResult? -
Runs the form and returns a FormResult on confirmation, or
nullif cancelled. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited