feat: added the options to disable the show password button

This commit is contained in:
mike doornenbal 2023-11-20 16:37:21 +01:00
parent 381c63960c
commit f46dd989de
5 changed files with 22 additions and 14 deletions

View file

@ -1,3 +1,6 @@
## 5.1.0
* Added the option to disable the showPassword button on the passwordfield.
## 5.0.0 ## 5.0.0
* Removed the redundant initialEmail parameter from 'ForgotPasswordForm'. The only one to use now is the one in the 'LoginOptions'. * Removed the redundant initialEmail parameter from 'ForgotPasswordForm'. The only one to use now is the one in the 'LoginOptions'.

View file

@ -68,7 +68,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "4.2.0" version: "5.0.0"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter

View file

@ -28,6 +28,7 @@ class LoginOptions {
this.registrationButtonBuilder = _createRegisterButton, this.registrationButtonBuilder = _createRegisterButton,
this.emailInputContainerBuilder = _createEmailInputContainer, this.emailInputContainerBuilder = _createEmailInputContainer,
this.passwordInputContainerBuilder = _createPasswordInputContainer, this.passwordInputContainerBuilder = _createPasswordInputContainer,
this.showObscurePassword = true,
}); });
final ButtonBuilder loginButtonBuilder; final ButtonBuilder loginButtonBuilder;
@ -55,6 +56,7 @@ class LoginOptions {
final TextStyle? passwordTextStyle; final TextStyle? passwordTextStyle;
final LoginTranslations translations; final LoginTranslations translations;
final ValidationService? validationService; final ValidationService? validationService;
final bool showObscurePassword;
ValidationService get validations => ValidationService get validations =>
validationService ?? LoginValidationService(this); validationService ?? LoginValidationService(this);

View file

@ -161,18 +161,21 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
style: options.passwordTextStyle, style: options.passwordTextStyle,
onFieldSubmitted: (_) => _handleLogin(), onFieldSubmitted: (_) => _handleLogin(),
decoration: options.passwordDecoration.copyWith( decoration: options.passwordDecoration.copyWith(
suffixIcon: IconButton( suffixIcon: options.showObscurePassword
onPressed: () { ? IconButton(
setState(() { onPressed: () {
_obscurePassword = !_obscurePassword; setState(() {
}); _obscurePassword =
}, !_obscurePassword;
icon: Icon( });
_obscurePassword },
? Icons.visibility icon: Icon(
: Icons.visibility_off, _obscurePassword
), ? Icons.visibility
), : Icons.visibility_off,
),
)
: null,
), ),
), ),
), ),

View file

@ -1,6 +1,6 @@
name: flutter_login name: flutter_login
description: Flutter Login Component description: Flutter Login Component
version: 5.0.0 version: 5.1.0
environment: environment:
sdk: ">=2.18.1 <3.0.0" sdk: ">=2.18.1 <3.0.0"