Created
July 17, 2019 05:55
-
-
Save trongdth/6eb3423888fbf8c8e1256a3a9ec20859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget _buildTextField(BuildContext context) { | |
if (widget.showClearBtn) { | |
return Row( | |
children: <Widget>[ | |
Expanded( | |
flex: 9, | |
child: TextField( | |
focusNode: _focusNode, | |
style: widget.txtStyle, | |
textAlign: TextAlign.left, | |
controller: txtController, | |
decoration: InputDecoration( | |
border: (widget.showBorder) ? UnderlineInputBorder() : InputBorder.none, | |
hintText: (isShowHintText) ? widget.hintText : '', | |
), | |
onTap: () => _onTap(), | |
onChanged: (value) => _onChanged(value), | |
onEditingComplete: () => _onComplete(), | |
), | |
), | |
(txtController.text.isNotEmpty) ? | |
Expanded( | |
flex: 1, | |
child: InkWell( | |
onTap: () { | |
txtController.text = ''; | |
setState(() {}); | |
}, | |
child: Icon(Icons.close, color: Colors.grey,), | |
), | |
) : | |
Container() | |
], | |
); | |
} | |
return TextField( | |
focusNode: _focusNode, | |
style: widget.txtStyle, | |
textAlign: TextAlign.left, | |
controller: txtController, | |
decoration: InputDecoration( | |
border: (widget.showBorder) ? UnderlineInputBorder() : InputBorder.none, | |
hintText: (isShowHintText) ? widget.hintText : '', | |
), | |
onTap: () => _onTap(), | |
onChanged: (value) => _onChanged(value), | |
onEditingComplete: () => _onComplete(), | |
); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Stack( | |
children: <Widget>[ | |
Align( | |
alignment: Alignment.bottomLeft, | |
child: Text( | |
(isShowHintText) ? '' : overlapText, | |
textAlign: TextAlign.start, | |
style: (txtController.text.isEmpty) ? widget.lblNormalStyle : widget.lblHighlightStyle, | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.fromLTRB(0, 10, 0, 0), | |
child: _buildTextField(context), | |
), | |
], | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment