Password field
Use a password field when the reader needs to enter a secret and briefly check their typing. The reveal action lets them make that choice.
Check your typing
#Type a sample word, reveal it, then conceal it again. The message below confirms that the field contains text.
components/password-field/appliance/check_secret.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class CheckSecret extends StatefulWidget {
const CheckSecret({super.key});
@override
State<CheckSecret> createState() => _CheckSecretState();
}
class _CheckSecretState extends State<CheckSecret> {
bool entered = false;
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 360),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AppliancePasswordField(
label: 'Sample password',
onChanged: (value) => setState(() => entered = value.isNotEmpty),
),
const SizedBox(height: 12),
Text(entered ? 'Sample entered' : 'Enter a sample word'),
],
),
);
}
Parameters
AppliancePasswordField API ↗label- Identifies the password even when the entry is concealed.
onChanged- Updates the confirmation when the entry becomes empty or nonempty.
Shared behaviour
- Keyboard and focus. Type in the field, then use Tab to reach the reveal action. Activate it again to conceal the word.
- Screen readers. The field has a password label and the reveal control has its own action name. Read the confirmation below without repeating the sample word.
- Direction and type. The field and its reveal action share the available width. Try the narrow frame with RTL and larger type.