buildTextField function

Widget buildTextField(
  1. {@required TextEditingController controller,
  2. Color cursorColor,
  3. double hintFontSize = 12,
  4. TextStyle hintStyle,
  5. bool autofocus = false,
  6. InputDecoration decoration,
  7. String hintText,
  8. int maxLength,
  9. EdgeInsets margin,
  10. TextAlign textAlign = TextAlign.left,
  11. bool enabled = true,
  12. double fontSize = 14,
  13. TextInputType textInputType,
  14. int maxLines,
  15. List<TextInputFormatter> textInputFormatters,
  16. FocusNode focusNode,
  17. bool obscureText,
  18. TextStyle textStyle}
)

Implementation

Widget buildTextField({@required TextEditingController controller, Color cursorColor, double hintFontSize = 12, TextStyle hintStyle, bool autofocus = false, InputDecoration decoration, String hintText, int maxLength, EdgeInsets margin, TextAlign textAlign = TextAlign.left, bool enabled = true, double fontSize = 14, TextInputType textInputType, int maxLines, List<TextInputFormatter> textInputFormatters, FocusNode focusNode, bool obscureText, TextStyle textStyle}){
  return Container(
    margin: margin,
    child: TextField(
      textInputAction: TextInputAction.done,
      focusNode: focusNode,
      maxLines: isEmpty(obscureText)? maxLines : isEmpty(maxLines)? 1 : maxLines,
      enabled: enabled,
      textAlign: textAlign,
      autofocus: autofocus,
      style: textStyle??TextStyle(fontSize: getSp(fontSize), color: Colors.black),
      maxLength: maxLength,
      keyboardType: textInputType,
      obscureText: obscureText??false,
      inputFormatters: textInputFormatters,
      cursorColor: cursorColor??Colors.blue,
      decoration: decoration??InputDecoration.collapsed(
        border: InputBorder.none,
        hintText: hintText,
        hintStyle: hintStyle??TextStyle(
          fontSize: getSp(hintFontSize),
          color: Colors.grey
        )
      ),
      cursorRadius: Radius.circular(3),
      controller: controller,
    ),
  );
}