Merge pull request #30 from Iconica-Development/feat/password_controller

Feat/password controller
This commit is contained in:
Jacques Doeleman 2024-02-07 16:15:31 +01:00 committed by Freek van de Ven
commit 1244353cb7
3 changed files with 13 additions and 2 deletions

View file

@ -66,3 +66,6 @@
## 3.0.0 ## 3.0.0
* Updated the FlutterFormInputSwitch to FlutterFormInputBool. This now includes a parameter to either show a checkbox or switch * Updated the FlutterFormInputSwitch to FlutterFormInputBool. This now includes a parameter to either show a checkbox or switch
## 3.1.0
* `FlutterFormInputPassword` now has the controller parameter to set the `TextEditingController` of the `TextFormField`

View file

@ -21,7 +21,9 @@ class FlutterFormInputPassword extends StatefulWidget {
this.onChanged, this.onChanged,
this.onFieldSubmitted, this.onFieldSubmitted,
this.enabled = true, this.enabled = true,
this.iconSize,
this.decoration, this.decoration,
this.controller,
}); });
final Widget? label; final Widget? label;
final FocusNode? focusNode; final FocusNode? focusNode;
@ -33,7 +35,9 @@ class FlutterFormInputPassword extends StatefulWidget {
final Function(String?)? onChanged; final Function(String?)? onChanged;
final Function(String?)? onFieldSubmitted; final Function(String?)? onFieldSubmitted;
final bool enabled; final bool enabled;
final double? iconSize;
final InputDecoration? decoration; final InputDecoration? decoration;
final TextEditingController? controller;
@override @override
State<FlutterFormInputPassword> createState() => _PasswordTextFieldState(); State<FlutterFormInputPassword> createState() => _PasswordTextFieldState();
@ -50,13 +54,17 @@ class _PasswordTextFieldState extends State<FlutterFormInputPassword> {
obscured = !obscured; obscured = !obscured;
}); });
}, },
icon: Icon(obscured ? Icons.visibility_off : Icons.visibility), icon: Icon(
obscured ? Icons.visibility_off : Icons.visibility,
size: widget.iconSize ?? 24.0,
),
); );
var decoration = widget.decoration?.copyWith(suffixIcon: suffixIcon) ?? var decoration = widget.decoration?.copyWith(suffixIcon: suffixIcon) ??
InputDecoration(suffixIcon: suffixIcon); InputDecoration(suffixIcon: suffixIcon);
return TextFormField( return TextFormField(
controller: widget.controller,
style: widget.style, style: widget.style,
initialValue: widget.initialValue, initialValue: widget.initialValue,
inputFormatters: widget.inputFormatters, inputFormatters: widget.inputFormatters,

View file

@ -1,6 +1,6 @@
name: flutter_input_library name: flutter_input_library
description: A new Flutter package project. description: A new Flutter package project.
version: 3.0.0 version: 3.1.0
repository: https://github.com/Iconica-Development/flutter_input_library repository: https://github.com/Iconica-Development/flutter_input_library
environment: environment: