PasswordModel class
A password input component following the Model architecture.
Displays a password prompt with masked input.
Example
final password = PasswordModel(
prompt: 'Enter password: ',
);
// In your update function:
switch (msg) {
case PasswordSubmittedMsg(:final password):
print('Password entered');
return (this, Cmd.quit());
case PasswordCancelledMsg():
return (this, Cmd.quit());
}
- Inheritance
-
- Object
- Model
- ViewComponent
- PasswordModel
Constructors
- PasswordModel({String prompt = 'Password: ', String placeholder = '', PasswordEchoMode echoMode = PasswordEchoMode.mask, String maskChar = '*', int fixedMaskLength = 6, int minLength = 0, int maxLength = 0, bool showHelp = false, String? validate(String)?, PasswordKeyMap? keyMap, PasswordStyles? styles, CursorModel? cursor})
- Creates a new password model.
Properties
- cursor ↔ CursorModel
-
Cursor model.
getter/setter pair
- echoMode → PasswordEchoMode
-
How to display the password.
final
- error → String?
-
Gets the current error message.
no setter
- fixedMaskLength → int
-
Fixed length for mask display (when echoMode is fixed).
final
- focused → bool
-
Gets whether the input is focused.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- keyMap → PasswordKeyMap
-
Key bindings.
final
- length → int
-
Gets the password length.
no setter
- maskChar → String
-
Character used to mask input.
final
- maxLength → int
-
Maximum password length (0 = no maximum).
final
- minLength → int
-
Minimum password length (0 = no minimum).
final
- placeholder → String
-
Placeholder text when empty.
final
- position → int
-
Gets the cursor position.
no setter
- prompt → String
-
The prompt to display.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showHelp → bool
-
Whether to show help text.
final
- styles → PasswordStyles
-
Styles.
final
- validate → String? Function(String)?
-
Validation function.
final
- value → String
-
Gets the current password value.
no setter
Methods
-
blur(
) → void - Blur the input.
-
focus(
) → Cmd? - Focus the input.
-
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.
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
Msg msg) → (PasswordModel, Cmd?) -
Updates the component state in response to a message.
override
-
view(
) → String -
Renders the current model state for display.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited