mirror of
https://github.com/Iconica-Development/flutter_input_library.git
synced 2025-05-18 17:03:45 +02:00
feat(password): Provide a decoration to the password field
This commit is contained in:
parent
4f0e548186
commit
92e7e74ef1
3 changed files with 20 additions and 13 deletions
|
@ -57,3 +57,6 @@
|
||||||
|
|
||||||
## 2.6.1
|
## 2.6.1
|
||||||
* Addition of 'obscureText' parameter to 'FlutterFormInputPlainText'
|
* Addition of 'obscureText' parameter to 'FlutterFormInputPlainText'
|
||||||
|
|
||||||
|
## 2.7.0
|
||||||
|
* Addition of 'decoration' parameter to 'FlutterFormInputPassword'
|
|
@ -18,6 +18,7 @@ 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 InputDecoration? decoration;
|
||||||
|
|
||||||
const FlutterFormInputPassword({
|
const FlutterFormInputPassword({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -31,6 +32,7 @@ class FlutterFormInputPassword extends StatefulWidget {
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.onFieldSubmitted,
|
this.onFieldSubmitted,
|
||||||
this.enabled = true,
|
this.enabled = true,
|
||||||
|
this.decoration,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -42,6 +44,18 @@ class _PasswordTextFieldState extends State<FlutterFormInputPassword> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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(
|
return TextFormField(
|
||||||
style: widget.style,
|
style: widget.style,
|
||||||
initialValue: widget.initialValue,
|
initialValue: widget.initialValue,
|
||||||
|
@ -52,17 +66,7 @@ class _PasswordTextFieldState extends State<FlutterFormInputPassword> {
|
||||||
validator: (value) => widget.validator?.call(value),
|
validator: (value) => widget.validator?.call(value),
|
||||||
onChanged: (value) => widget.onChanged?.call(value),
|
onChanged: (value) => widget.onChanged?.call(value),
|
||||||
onFieldSubmitted: (value) => widget.onFieldSubmitted?.call(value),
|
onFieldSubmitted: (value) => widget.onFieldSubmitted?.call(value),
|
||||||
decoration: InputDecoration(
|
decoration: decoration,
|
||||||
label: widget.label ?? const Text("Password"),
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
obscured = !obscured;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
icon: Icon(obscured ? Icons.visibility_off : Icons.visibility),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
enabled: widget.enabled,
|
enabled: widget.enabled,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: 2.6.1
|
version: 2.7.0
|
||||||
repository: https://github.com/Iconica-Development/flutter_input_library
|
repository: https://github.com/Iconica-Development/flutter_input_library
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue