|
|
|
@ -76,7 +76,8 @@ class TextFields extends StatefulWidget {
|
|
|
|
|
this.hintColor,
|
|
|
|
|
this.hasBorder = true,
|
|
|
|
|
this.onTapTextFields,
|
|
|
|
|
this.hasLabelText = false, this.showLabelText= false})
|
|
|
|
|
this.hasLabelText = false,
|
|
|
|
|
this.showLabelText = false})
|
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
final String hintText;
|
|
|
|
@ -233,22 +234,21 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
|
maxLines: widget.maxLines ?? 1,
|
|
|
|
|
maxLengthEnforced: widget.maxLengthEnforced,
|
|
|
|
|
initialValue: widget.initialValue,
|
|
|
|
|
onChanged: (value){
|
|
|
|
|
if(widget.showLabelText) {
|
|
|
|
|
if((value== null || value =='' )) {
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
if (widget.showLabelText) {
|
|
|
|
|
if ((value == null || value == '')) {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.hasLabelText = false;
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.hasLabelText = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
widget.onChanged(value);
|
|
|
|
|
} ,
|
|
|
|
|
},
|
|
|
|
|
focusNode: _focusNode,
|
|
|
|
|
maxLength: widget.maxLength ?? null,
|
|
|
|
|
controller: widget.controller,
|
|
|
|
@ -258,10 +258,8 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
|
autofocus: widget.autoFocus ?? false,
|
|
|
|
|
validator: widget.validator,
|
|
|
|
|
onSaved: widget.onSaved,
|
|
|
|
|
style: Theme.of(context)
|
|
|
|
|
.textTheme
|
|
|
|
|
.bodyText1
|
|
|
|
|
.copyWith(fontSize: widget.fontSize, fontWeight: widget.fontWeight),
|
|
|
|
|
style: Theme.of(context).textTheme.bodyText1.copyWith(
|
|
|
|
|
fontSize: widget.fontSize, fontWeight: widget.fontWeight),
|
|
|
|
|
inputFormatters: widget.keyboardType == TextInputType.phone
|
|
|
|
|
? <TextInputFormatter>[
|
|
|
|
|
WhitelistingTextInputFormatter.digitsOnly,
|
|
|
|
@ -271,33 +269,27 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
labelText: widget.hasLabelText ? widget.hintText : null,
|
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
|
|
|
|
|
fontSize: widget.fontSize,
|
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
|
color: widget.hintColor ?? Theme
|
|
|
|
|
.of(context)
|
|
|
|
|
.hintColor,
|
|
|
|
|
color: widget.hintColor ?? Theme.of(context).hintColor,
|
|
|
|
|
),
|
|
|
|
|
counterText: "",
|
|
|
|
|
hintText: widget.hintText,
|
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
|
fontSize: widget.fontSize,
|
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
|
color: widget.hintColor ?? Theme
|
|
|
|
|
.of(context)
|
|
|
|
|
.hintColor,
|
|
|
|
|
color: widget.hintColor ?? Theme.of(context).hintColor,
|
|
|
|
|
),
|
|
|
|
|
contentPadding: widget.padding != null
|
|
|
|
|
? widget.padding
|
|
|
|
|
: EdgeInsets.symmetric(
|
|
|
|
|
vertical: (widget.bare && !widget.keepPadding) ? 0.0 : 10.0,
|
|
|
|
|
horizontal: 16.0),
|
|
|
|
|
vertical:
|
|
|
|
|
(widget.bare && !widget.keepPadding) ? 0.0 : 10.0,
|
|
|
|
|
horizontal: 16.0),
|
|
|
|
|
filled: true,
|
|
|
|
|
fillColor: widget.bare
|
|
|
|
|
? Colors.transparent
|
|
|
|
|
: Theme
|
|
|
|
|
.of(context)
|
|
|
|
|
.backgroundColor,
|
|
|
|
|
: Theme.of(context).backgroundColor,
|
|
|
|
|
suffixIcon: _buildSuffixIcon(),
|
|
|
|
|
prefixIcon: widget.prefixIcon,
|
|
|
|
|
errorStyle: TextStyle(
|
|
|
|
@ -305,48 +297,53 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
|
height: widget.borderOnlyError ? 0.0 : null),
|
|
|
|
|
errorBorder: OutlineInputBorder(
|
|
|
|
|
borderSide: widget.hasBorder ? BorderSide(
|
|
|
|
|
color: Theme
|
|
|
|
|
.of(context)
|
|
|
|
|
.errorColor
|
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
|
width: 1.0) : BorderSide(
|
|
|
|
|
color: Colors.transparent, width: 0),
|
|
|
|
|
borderRadius: widget.hasBorder ? BorderRadius.circular(
|
|
|
|
|
widget.bare ? 0.0 : 8.0) : BorderRadius.circular(0.0),),
|
|
|
|
|
borderSide: widget.hasBorder
|
|
|
|
|
? BorderSide(
|
|
|
|
|
color: Theme.of(context)
|
|
|
|
|
.errorColor
|
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
|
width: 1.0)
|
|
|
|
|
: BorderSide(color: Colors.transparent, width: 0),
|
|
|
|
|
borderRadius: widget.hasBorder
|
|
|
|
|
? BorderRadius.circular(widget.bare ? 0.0 : 8.0)
|
|
|
|
|
: BorderRadius.circular(0.0),
|
|
|
|
|
),
|
|
|
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
|
|
|
borderSide: widget.hasBorder ? BorderSide(
|
|
|
|
|
color: Theme
|
|
|
|
|
.of(context)
|
|
|
|
|
.errorColor
|
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
|
width: 1.0) : BorderSide(
|
|
|
|
|
color: Colors.transparent, width: 0),
|
|
|
|
|
borderSide: widget.hasBorder
|
|
|
|
|
? BorderSide(
|
|
|
|
|
color: Theme.of(context)
|
|
|
|
|
.errorColor
|
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
|
width: 1.0)
|
|
|
|
|
: BorderSide(color: Colors.transparent, width: 0),
|
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)),
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
|
borderSide: widget.hasBorder ? BorderSide(
|
|
|
|
|
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),),
|
|
|
|
|
borderSide: widget.hasBorder
|
|
|
|
|
? BorderSide(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(
|
|
|
|
|
borderSide: widget.hasBorder ? BorderSide(
|
|
|
|
|
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)),
|
|
|
|
|
borderSide: widget.hasBorder
|
|
|
|
|
? BorderSide(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(
|
|
|
|
|
borderSide: widget.hasBorder ? BorderSide(
|
|
|
|
|
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),
|
|
|
|
|
borderSide: widget.hasBorder
|
|
|
|
|
? BorderSide(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),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|