From b9674d7ada55c24e902409eedd8bc8bf3bdf9226 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 7 Dec 2023 14:29:38 +0100 Subject: [PATCH] feat: add formatInputs parameter to FlutterFormInputPlainText and FlutterFormInputPassword --- CHANGELOG.md | 6 +++++- lib/src/inputs/text/password.dart | 4 ++++ lib/src/inputs/text/plain_text.dart | 4 ++++ pubspec.yaml | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2511934..aa5ca42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,4 +43,8 @@ * FlutterFormInputDateTime now also had the enabled parameter to provide to DateTimeInputField ## 2.5.0 -* Addition of the ScrollPicker input field. \ No newline at end of file +* Addition of the ScrollPicker input field. + +## 2.5.1 +* Addition of `formatInputs` parameter to `FlutterFormInputPlainText` widget. +* Addition of `formatInputs` parameter to `FlutterFormInputPassword` widget. \ No newline at end of file diff --git a/lib/src/inputs/text/password.dart b/lib/src/inputs/text/password.dart index 681053a..692806a 100644 --- a/lib/src/inputs/text/password.dart +++ b/lib/src/inputs/text/password.dart @@ -3,6 +3,7 @@ // SPDX-License-Identifier: BSD-3-Clause import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; /// Generates a [TextFormField] for passwords. It requires a [FlutterFormInputController] /// as the [controller] parameter and an optional [Widget] as [label] @@ -10,6 +11,7 @@ class FlutterFormInputPassword extends StatefulWidget { final Widget? label; final FocusNode? focusNode; final String? initialValue; + final List? inputFormatters; final Function(String?)? onSaved; final String? Function(String?)? validator; final Function(String?)? onChanged; @@ -21,6 +23,7 @@ class FlutterFormInputPassword extends StatefulWidget { this.label, this.focusNode, this.initialValue, + this.inputFormatters, this.onSaved, this.validator, this.onChanged, @@ -39,6 +42,7 @@ class _PasswordTextFieldState extends State { Widget build(BuildContext context) { return TextFormField( initialValue: widget.initialValue, + inputFormatters: widget.inputFormatters, obscureText: obscured, focusNode: widget.focusNode, onSaved: (value) => widget.onSaved?.call(value), diff --git a/lib/src/inputs/text/plain_text.dart b/lib/src/inputs/text/plain_text.dart index 7eaacd3..8164a3c 100644 --- a/lib/src/inputs/text/plain_text.dart +++ b/lib/src/inputs/text/plain_text.dart @@ -3,6 +3,7 @@ // SPDX-License-Identifier: BSD-3-Clause import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; class FlutterFormInputPlainText extends StatelessWidget { const FlutterFormInputPlainText({ @@ -22,6 +23,7 @@ class FlutterFormInputPlainText extends StatelessWidget { this.validator, this.onFieldSubmitted, this.style, + this.formatInputs, this.enabled = true, }) : super( key: key, @@ -42,6 +44,7 @@ class FlutterFormInputPlainText extends StatelessWidget { final Function(String?)? onChanged; final Function(String?)? onFieldSubmitted; final TextStyle? style; + final List? formatInputs; final bool enabled; @override @@ -53,6 +56,7 @@ class FlutterFormInputPlainText extends StatelessWidget { return TextFormField( style: style, + inputFormatters: formatInputs, scrollPadding: scrollPadding ?? const EdgeInsets.all(20.0), initialValue: initialValue, focusNode: focusNode, diff --git a/pubspec.yaml b/pubspec.yaml index e2e52e4..a93cbfe 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_input_library description: A new Flutter package project. -version: 2.5.0 +version: 2.5.1 repository: https://github.com/Iconica-Development/flutter_input_library environment: