diff --git a/CHANGELOG.md b/CHANGELOG.md index 162bbd1..3cbed76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,4 +56,7 @@ * Addition of the `textCapitalization` parameter to `FlutterFormInputPlainText` and `FlutterFormInputMultiLine`. ## 2.6.1 -* Addition of 'obscureText' parameter to 'FlutterFormInputPlainText' \ No newline at end of file +* Addition of 'obscureText' parameter to 'FlutterFormInputPlainText' + +## 2.7.0 +* Addition of 'decoration' parameter to 'FlutterFormInputPassword' \ No newline at end of file diff --git a/lib/src/inputs/text/password.dart b/lib/src/inputs/text/password.dart index 2627652..76eb082 100644 --- a/lib/src/inputs/text/password.dart +++ b/lib/src/inputs/text/password.dart @@ -18,6 +18,7 @@ class FlutterFormInputPassword extends StatefulWidget { final Function(String?)? onChanged; final Function(String?)? onFieldSubmitted; final bool enabled; + final InputDecoration? decoration; const FlutterFormInputPassword({ Key? key, @@ -31,6 +32,7 @@ class FlutterFormInputPassword extends StatefulWidget { this.onChanged, this.onFieldSubmitted, this.enabled = true, + this.decoration, }) : super(key: key); @override @@ -42,6 +44,18 @@ class _PasswordTextFieldState extends State { @override Widget build(BuildContext context) { + var suffixIcon = IconButton( + onPressed: () { + setState(() { + obscured = !obscured; + }); + }, + icon: Icon(obscured ? Icons.visibility_off : Icons.visibility), + ); + + var decoration = widget.decoration?.copyWith(suffixIcon: suffixIcon) ?? + InputDecoration(suffixIcon: suffixIcon); + return TextFormField( style: widget.style, initialValue: widget.initialValue, @@ -52,17 +66,7 @@ class _PasswordTextFieldState extends State { validator: (value) => widget.validator?.call(value), onChanged: (value) => widget.onChanged?.call(value), onFieldSubmitted: (value) => widget.onFieldSubmitted?.call(value), - decoration: InputDecoration( - label: widget.label ?? const Text("Password"), - suffixIcon: IconButton( - onPressed: () { - setState(() { - obscured = !obscured; - }); - }, - icon: Icon(obscured ? Icons.visibility_off : Icons.visibility), - ), - ), + decoration: decoration, enabled: widget.enabled, ); } diff --git a/pubspec.yaml b/pubspec.yaml index 3cb0839..145ad3a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_input_library description: A new Flutter package project. -version: 2.6.1 +version: 2.7.0 repository: https://github.com/Iconica-Development/flutter_input_library environment: