mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Adds autofillHints property with AutofillHints.password to the password TextFormField in PasswordField widget. This enables password managers like Bitwarden to properly detect and autofill password fields on Android devices. Without this hint, the Android autofill framework cannot identify the field as a password input, preventing password managers from offering autofill suggestions. Changes: - Added autofillHints: const [AutofillHints.password] to TextFormField in lib/widgets/auth/password_field.dart Tested on Android with Bitwarden password manager.
51 lines
1.4 KiB
Dart
51 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:wger/l10n/generated/app_localizations.dart';
|
|
|
|
class PasswordField extends StatefulWidget {
|
|
final TextEditingController controller;
|
|
final Function(String?) onSaved;
|
|
|
|
const PasswordField({
|
|
required this.controller,
|
|
required this.onSaved,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
_PasswordFieldState createState() => _PasswordFieldState();
|
|
}
|
|
|
|
class _PasswordFieldState extends State<PasswordField> {
|
|
bool isObscure = true;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return TextFormField(
|
|
key: const Key('inputPassword'),
|
|
autofillHints: const [AutofillHints.password],
|
|
decoration: InputDecoration(
|
|
labelText: AppLocalizations.of(context).password,
|
|
prefixIcon: const Icon(Icons.password),
|
|
suffixIcon: IconButton(
|
|
icon: Icon(isObscure ? Icons.visibility_off : Icons.visibility),
|
|
onPressed: () {
|
|
setState(() {
|
|
isObscure = !isObscure;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
obscureText: isObscure,
|
|
controller: widget.controller,
|
|
textInputAction: TextInputAction.next,
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty || value.length < 8) {
|
|
return AppLocalizations.of(context).passwordTooShort;
|
|
}
|
|
return null;
|
|
},
|
|
onSaved: widget.onSaved,
|
|
);
|
|
}
|
|
}
|