|
|
|
@ -74,7 +74,9 @@ class TextFields extends StatefulWidget {
|
|
|
|
this.autoValidate = false,
|
|
|
|
this.autoValidate = false,
|
|
|
|
this.fillColor,
|
|
|
|
this.fillColor,
|
|
|
|
this.hintColor,
|
|
|
|
this.hintColor,
|
|
|
|
this.onTapTextFields})
|
|
|
|
this.hasBorder = true,
|
|
|
|
|
|
|
|
this.onTapTextFields,
|
|
|
|
|
|
|
|
this.hasLabelText = false, this.showLabelText= false})
|
|
|
|
: super(key: key);
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
final String hintText;
|
|
|
|
final String hintText;
|
|
|
|
@ -111,6 +113,9 @@ class TextFields extends StatefulWidget {
|
|
|
|
final bool borderOnlyError;
|
|
|
|
final bool borderOnlyError;
|
|
|
|
final Color hintColor;
|
|
|
|
final Color hintColor;
|
|
|
|
final Color fillColor;
|
|
|
|
final Color fillColor;
|
|
|
|
|
|
|
|
final bool hasBorder;
|
|
|
|
|
|
|
|
final bool showLabelText;
|
|
|
|
|
|
|
|
bool hasLabelText;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
_TextFieldsState createState() => _TextFieldsState();
|
|
|
|
_TextFieldsState createState() => _TextFieldsState();
|
|
|
|
@ -208,7 +213,9 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
offset: Offset(0.0, 13.0),
|
|
|
|
offset: Offset(0.0, 13.0),
|
|
|
|
blurRadius: focus ? 34.0 : 12.0)
|
|
|
|
blurRadius: focus ? 34.0 : 12.0)
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
child: TextFormField(
|
|
|
|
child: Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
TextFormField(
|
|
|
|
onTap: widget.onTapTextFields,
|
|
|
|
onTap: widget.onTapTextFields,
|
|
|
|
keyboardAppearance: Theme.of(context).brightness,
|
|
|
|
keyboardAppearance: Theme.of(context).brightness,
|
|
|
|
scrollPhysics: BouncingScrollPhysics(),
|
|
|
|
scrollPhysics: BouncingScrollPhysics(),
|
|
|
|
@ -226,7 +233,22 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
maxLines: widget.maxLines ?? 1,
|
|
|
|
maxLines: widget.maxLines ?? 1,
|
|
|
|
maxLengthEnforced: widget.maxLengthEnforced,
|
|
|
|
maxLengthEnforced: widget.maxLengthEnforced,
|
|
|
|
initialValue: widget.initialValue,
|
|
|
|
initialValue: widget.initialValue,
|
|
|
|
onChanged: widget.onChanged,
|
|
|
|
onChanged: (value){
|
|
|
|
|
|
|
|
if(widget.showLabelText) {
|
|
|
|
|
|
|
|
if((value== null || value =='' )) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
widget.hasLabelText = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
widget.hasLabelText = true;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
widget.onChanged(value);
|
|
|
|
|
|
|
|
} ,
|
|
|
|
focusNode: _focusNode,
|
|
|
|
focusNode: _focusNode,
|
|
|
|
maxLength: widget.maxLength ?? null,
|
|
|
|
maxLength: widget.maxLength ?? null,
|
|
|
|
controller: widget.controller,
|
|
|
|
controller: widget.controller,
|
|
|
|
@ -247,12 +269,23 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
]
|
|
|
|
]
|
|
|
|
: widget.inputFormatters,
|
|
|
|
: widget.inputFormatters,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
|
|
|
labelText: widget.hasLabelText ? widget.hintText : null,
|
|
|
|
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fontSize: widget.fontSize,
|
|
|
|
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
|
|
|
|
color: widget.hintColor ?? Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
|
|
|
|
.hintColor,
|
|
|
|
|
|
|
|
),
|
|
|
|
counterText: "",
|
|
|
|
counterText: "",
|
|
|
|
hintText: widget.hintText,
|
|
|
|
hintText: widget.hintText,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
fontSize: widget.fontSize,
|
|
|
|
fontSize: widget.fontSize,
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
color: widget.hintColor ?? Theme.of(context).hintColor,
|
|
|
|
color: widget.hintColor ?? Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
|
|
|
|
.hintColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
contentPadding: widget.padding != null
|
|
|
|
contentPadding: widget.padding != null
|
|
|
|
? widget.padding
|
|
|
|
? widget.padding
|
|
|
|
@ -262,7 +295,9 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
filled: true,
|
|
|
|
filled: true,
|
|
|
|
fillColor: widget.bare
|
|
|
|
fillColor: widget.bare
|
|
|
|
? Colors.transparent
|
|
|
|
? Colors.transparent
|
|
|
|
: Theme.of(context).backgroundColor,
|
|
|
|
: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
|
|
|
|
.backgroundColor,
|
|
|
|
suffixIcon: _buildSuffixIcon(),
|
|
|
|
suffixIcon: _buildSuffixIcon(),
|
|
|
|
prefixIcon: widget.prefixIcon,
|
|
|
|
prefixIcon: widget.prefixIcon,
|
|
|
|
errorStyle: TextStyle(
|
|
|
|
errorStyle: TextStyle(
|
|
|
|
@ -270,31 +305,48 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
height: widget.borderOnlyError ? 0.0 : null),
|
|
|
|
height: widget.borderOnlyError ? 0.0 : null),
|
|
|
|
errorBorder: OutlineInputBorder(
|
|
|
|
errorBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
borderSide: widget.hasBorder ? BorderSide(
|
|
|
|
color: Theme.of(context)
|
|
|
|
color: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
.errorColor
|
|
|
|
.errorColor
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
width: 1.0),
|
|
|
|
width: 1.0) : BorderSide(
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)),
|
|
|
|
color: Colors.transparent, width: 0),
|
|
|
|
|
|
|
|
borderRadius: widget.hasBorder ? BorderRadius.circular(
|
|
|
|
|
|
|
|
widget.bare ? 0.0 : 8.0) : BorderRadius.circular(0.0),),
|
|
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
borderSide: widget.hasBorder ? BorderSide(
|
|
|
|
color: Theme.of(context)
|
|
|
|
color: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
.errorColor
|
|
|
|
.errorColor
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
width: 1.0),
|
|
|
|
width: 1.0) : BorderSide(
|
|
|
|
|
|
|
|
color: Colors.transparent, width: 0),
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)),
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)),
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: Colors.grey, width: 1.0),
|
|
|
|
borderSide: widget.hasBorder ? BorderSide(
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)),
|
|
|
|
color: Colors.grey, width: 1.0) : BorderSide(
|
|
|
|
|
|
|
|
color: Colors.transparent, width: 0),
|
|
|
|
|
|
|
|
borderRadius: widget.hasBorder ? BorderRadius.circular(
|
|
|
|
|
|
|
|
widget.bare ? 0.0 : 8.0) : BorderRadius.circular(0.0),),
|
|
|
|
disabledBorder: OutlineInputBorder(
|
|
|
|
disabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: Colors.grey, width: 1.0),
|
|
|
|
borderSide: widget.hasBorder ? BorderSide(
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)),
|
|
|
|
color: Colors.grey, width: 1.0) : BorderSide(
|
|
|
|
|
|
|
|
color: Colors.transparent, width: 0),
|
|
|
|
|
|
|
|
borderRadius: widget.hasBorder ? BorderRadius.circular(
|
|
|
|
|
|
|
|
widget.bare ? 0.0 : 8.0) : BorderRadius.circular(0.0)),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: Colors.grey, width: 1.0),
|
|
|
|
borderSide: widget.hasBorder ? BorderSide(
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0),
|
|
|
|
color: Colors.grey, width: 1.0) : BorderSide(
|
|
|
|
|
|
|
|
color: Colors.transparent, width: 0),
|
|
|
|
|
|
|
|
borderRadius: widget.hasBorder ? BorderRadius.circular(
|
|
|
|
|
|
|
|
widget.bare ? 0.0 : 8.0) : BorderRadius.circular(0.0),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|