in this textfiled i use expands and maxline both but show error how to set maxline 1. this textfiled i used in resizable container when the container size go small the text font go to new line but i have set text in same line it is adjust using when the size of container decrease the font adjust using of the font size decrease.
child: TextField(
textAlign: TextAlign.center,
textAlignVertical: TextAlignVertical.center,
expands: true,
maxLines: null, //here i use 1 but error...
key: textFieldKey,
controller: textController,
cursorColor: Colors.black,
style: TextStyle(color: Colors.black, fontSize: fontSize),
decoration: InputDecoration(
filled: true,
fillColor: Colors.yellow,
hintText: "Enter Your Text",
helperStyle: TextStyle(color: Colors.black),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
vertical: height / 20), // Adjust the vertical padding
),
onChanged: (text) {
updateDimensions();
},
onSubmitted: (text) {
setState(() {
_isSelected = false;
});
},
),
I think what you fail to realize is that
maxLinesis not meant for limiting how many lines of text you allow. It's maybe a bit of deceiving name. As per documentation aboutmaxLines:For that you can for example use an inputFormatter like
EDIT:
I looked further into it and it seems that putting
might be sufficient. There's actually code inside
TextFieldthat doesMeaning that if you don't specify a keyboardType it makes it a multline one when
maxLinesisn't 1