Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter when text is bigger than input, text disappears

Tags:

flutter

The problem is that when the text is bigger than the input size, the text just disappears and I don't know why.

Here is my code:

TextField(
    focusNode: _focusEmailNode,
    controller: _emailController,
    decoration: InputDecoration(
    border: OutlineInputBorder(),
    enabledBorder: OutlineInputBorder(
        borderSide: BorderSide(color: txtEmailBoder),
    ),
    hintText: 'Email',
),

enter image description here

like image 647
YeisonM Avatar asked Dec 30 '19 19:12

YeisonM


1 Answers

After searching through many sites, I finally got a solution. You can solve this problem by giving decoration and maxlines in the textfield. Give isDense as true in InputDecoration Example:

Container(
  height: 20,
  width: 100,
  child: TextFormField(
    maxLines: 1,
    decoration: InputDecoration(
      isDense: true,
      contentPadding: EdgeInsets.fromLTRB(5.0, 1.0, 5.0, 1.0),
    ),
    onChanged: (value) {
      print(value);
    },
  ),
);

if you don't give content padding then your text will be cut from the middle, like below. enter image description here

Be careful when you give padding, you should give padding as needed by your textfield's height. If you give wrong padding then also your text will be invisible.

like image 121
devu mani Avatar answered Oct 09 '22 22:10

devu mani