|
|
|
|
@ -39,46 +39,49 @@ class NumberTextInputFormatter extends TextInputFormatter {
|
|
|
|
|
final _mobileFormatter = NumberTextInputFormatter();
|
|
|
|
|
|
|
|
|
|
class TextFields extends StatefulWidget {
|
|
|
|
|
TextFields(
|
|
|
|
|
{Key key,
|
|
|
|
|
this.type,
|
|
|
|
|
this.hintText,
|
|
|
|
|
this.suffixIcon,
|
|
|
|
|
this.autoFocus,
|
|
|
|
|
this.onChanged,
|
|
|
|
|
this.initialValue,
|
|
|
|
|
this.minLines,
|
|
|
|
|
this.maxLines,
|
|
|
|
|
this.inputFormatters,
|
|
|
|
|
this.padding,
|
|
|
|
|
this.focus = false,
|
|
|
|
|
this.maxLengthEnforced = true,
|
|
|
|
|
this.suffixIconColor,
|
|
|
|
|
this.inputAction = TextInputAction.done,
|
|
|
|
|
this.onSubmit,
|
|
|
|
|
this.keepPadding = true,
|
|
|
|
|
this.textCapitalization = TextCapitalization.none,
|
|
|
|
|
this.controller,
|
|
|
|
|
this.keyboardType,
|
|
|
|
|
this.validator,
|
|
|
|
|
this.borderOnlyError = false,
|
|
|
|
|
this.onSaved,
|
|
|
|
|
this.onSuffixTap,
|
|
|
|
|
this.readOnly: false,
|
|
|
|
|
this.maxLength,
|
|
|
|
|
this.prefixIcon,
|
|
|
|
|
this.bare = false,
|
|
|
|
|
this.onTap,
|
|
|
|
|
this.fontSize = 16.0,
|
|
|
|
|
this.fontWeight = FontWeight.w700,
|
|
|
|
|
this.autoValidate = false,
|
|
|
|
|
this.fillColor,
|
|
|
|
|
this.hintColor,
|
|
|
|
|
this.hasBorder = true,
|
|
|
|
|
this.onTapTextFields,
|
|
|
|
|
this.hasLabelText = false,
|
|
|
|
|
this.showLabelText = false, this.borderRadius= 8.0, this.borderColor, this.borderWidth = 1, })
|
|
|
|
|
: super(key: key);
|
|
|
|
|
TextFields({
|
|
|
|
|
Key key,
|
|
|
|
|
this.type,
|
|
|
|
|
this.hintText,
|
|
|
|
|
this.suffixIcon,
|
|
|
|
|
this.autoFocus,
|
|
|
|
|
this.onChanged,
|
|
|
|
|
this.initialValue,
|
|
|
|
|
this.minLines,
|
|
|
|
|
this.maxLines,
|
|
|
|
|
this.inputFormatters,
|
|
|
|
|
this.padding,
|
|
|
|
|
this.focus = false,
|
|
|
|
|
this.maxLengthEnforced = true,
|
|
|
|
|
this.suffixIconColor,
|
|
|
|
|
this.inputAction = TextInputAction.done,
|
|
|
|
|
this.onSubmit,
|
|
|
|
|
this.keepPadding = true,
|
|
|
|
|
this.textCapitalization = TextCapitalization.none,
|
|
|
|
|
this.controller,
|
|
|
|
|
this.keyboardType,
|
|
|
|
|
this.validator,
|
|
|
|
|
this.borderOnlyError = false,
|
|
|
|
|
this.onSaved,
|
|
|
|
|
this.onSuffixTap,
|
|
|
|
|
this.readOnly: false,
|
|
|
|
|
this.maxLength,
|
|
|
|
|
this.prefixIcon,
|
|
|
|
|
this.bare = false,
|
|
|
|
|
this.onTap,
|
|
|
|
|
this.fontSize = 16.0,
|
|
|
|
|
this.fontWeight = FontWeight.w700,
|
|
|
|
|
this.autoValidate,
|
|
|
|
|
this.fillColor,
|
|
|
|
|
this.hintColor,
|
|
|
|
|
this.hasBorder = true,
|
|
|
|
|
this.onTapTextFields,
|
|
|
|
|
this.hasLabelText = false,
|
|
|
|
|
this.showLabelText = false,
|
|
|
|
|
this.borderRadius = 8.0,
|
|
|
|
|
this.borderColor,
|
|
|
|
|
this.borderWidth = 1,
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
final String hintText;
|
|
|
|
|
final String initialValue;
|
|
|
|
|
@ -108,7 +111,7 @@ class TextFields extends StatefulWidget {
|
|
|
|
|
final bool keepPadding;
|
|
|
|
|
final TextCapitalization textCapitalization;
|
|
|
|
|
final List<TextInputFormatter> inputFormatters;
|
|
|
|
|
final bool autoValidate;
|
|
|
|
|
final AutovalidateMode autoValidate;
|
|
|
|
|
final EdgeInsets padding;
|
|
|
|
|
final bool focus;
|
|
|
|
|
final bool borderOnlyError;
|
|
|
|
|
@ -203,8 +206,7 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
|
|
widget.borderColor = widget.borderColor?? Colors.grey;
|
|
|
|
|
widget.borderColor = widget.borderColor ?? Colors.grey;
|
|
|
|
|
return (AnimatedContainer(
|
|
|
|
|
duration: Duration(milliseconds: 300),
|
|
|
|
|
decoration: widget.bare
|
|
|
|
|
@ -225,7 +227,7 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
|
onTap: widget.onTapTextFields,
|
|
|
|
|
keyboardAppearance: Theme.of(context).brightness,
|
|
|
|
|
scrollPhysics: BouncingScrollPhysics(),
|
|
|
|
|
autovalidate: widget.autoValidate,
|
|
|
|
|
autovalidateMode: widget.autoValidate,
|
|
|
|
|
textCapitalization: widget.textCapitalization,
|
|
|
|
|
onFieldSubmitted: widget.inputAction == TextInputAction.next
|
|
|
|
|
? (widget.onSubmit != null
|
|
|
|
|
@ -266,7 +268,7 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
|
fontSize: widget.fontSize, fontWeight: widget.fontWeight),
|
|
|
|
|
inputFormatters: widget.keyboardType == TextInputType.phone
|
|
|
|
|
? <TextInputFormatter>[
|
|
|
|
|
WhitelistingTextInputFormatter.digitsOnly,
|
|
|
|
|
FilteringTextInputFormatter.digitsOnly,
|
|
|
|
|
_mobileFormatter,
|
|
|
|
|
]
|
|
|
|
|
: widget.inputFormatters,
|
|
|
|
|
@ -281,7 +283,6 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
|
hintText: widget.hintText,
|
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
|
fontSize: widget.fontSize,
|
|
|
|
|
|
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
|
color: widget.hintColor ?? Theme.of(context).hintColor,
|
|
|
|
|
),
|
|
|
|
|
@ -310,7 +311,8 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
|
width: 1.0)
|
|
|
|
|
: BorderSide(color: Colors.transparent, width: 0),
|
|
|
|
|
borderRadius: widget.hasBorder
|
|
|
|
|
? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius)
|
|
|
|
|
? BorderRadius.circular(
|
|
|
|
|
widget.bare ? 0.0 : widget.borderRadius)
|
|
|
|
|
: BorderRadius.circular(0.0),
|
|
|
|
|
),
|
|
|
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
|
|
|
@ -321,28 +323,35 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
|
width: 1.0)
|
|
|
|
|
: BorderSide(color: Colors.transparent, width: 0),
|
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius)),
|
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
|
widget.bare ? 0.0 : widget.borderRadius)),
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
|
borderSide: widget.hasBorder
|
|
|
|
|
? BorderSide(color: widget.borderColor,width: widget.borderWidth)
|
|
|
|
|
? BorderSide(
|
|
|
|
|
color: widget.borderColor, width: widget.borderWidth)
|
|
|
|
|
: BorderSide(color: Colors.transparent, width: 0),
|
|
|
|
|
borderRadius: widget.hasBorder
|
|
|
|
|
? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius)
|
|
|
|
|
? BorderRadius.circular(
|
|
|
|
|
widget.bare ? 0.0 : widget.borderRadius)
|
|
|
|
|
: BorderRadius.circular(0.0),
|
|
|
|
|
),
|
|
|
|
|
disabledBorder: OutlineInputBorder(
|
|
|
|
|
borderSide: widget.hasBorder
|
|
|
|
|
? BorderSide(color: widget.borderColor,width: widget.borderWidth)
|
|
|
|
|
? BorderSide(
|
|
|
|
|
color: widget.borderColor, width: widget.borderWidth)
|
|
|
|
|
: BorderSide(color: Colors.transparent, width: 0),
|
|
|
|
|
borderRadius: widget.hasBorder
|
|
|
|
|
? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius)
|
|
|
|
|
? BorderRadius.circular(
|
|
|
|
|
widget.bare ? 0.0 : widget.borderRadius)
|
|
|
|
|
: BorderRadius.circular(0.0)),
|
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
|
borderSide: widget.hasBorder
|
|
|
|
|
? BorderSide(color: widget.borderColor,width: widget.borderWidth)
|
|
|
|
|
? BorderSide(
|
|
|
|
|
color: widget.borderColor, width: widget.borderWidth)
|
|
|
|
|
: BorderSide(color: Colors.transparent, width: 0),
|
|
|
|
|
borderRadius: widget.hasBorder
|
|
|
|
|
? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius)
|
|
|
|
|
? BorderRadius.circular(
|
|
|
|
|
widget.bare ? 0.0 : widget.borderRadius)
|
|
|
|
|
: BorderRadius.circular(0.0),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|