PasswordFieldMixin mixin
A mixin that provides functionality for managing password field visibility in text input widgets.
This mixin is typically used with Flutter text field widgets (such as TextField or TextFormField) to enable users to toggle between showing and hiding password characters. It maintains the visibility state and provides a method to toggle it.
Example usage:
class LoginForm extends StatefulWidget {
@override
_LoginFormState createState() => _LoginFormState();
}
class _LoginFormState extends State<LoginForm> with PasswordFieldMixin {
@override
Widget build(BuildContext context) {
return TextField(
obscureText: !isShowPassword,
decoration: InputDecoration(
suffixIcon: IconButton(
icon: Icon(isShowPassword ? Icons.visibility : Icons.visibility_off),
onPressed: toggleShowPassword,
),
),
);
}
}
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isShowPassword ↔ bool
-
Indicates whether the password text is currently visible to the user.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toggleShowPassword(
) → void - Toggles the visibility state of the password field.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited