Home > Back-end >  How to Create small TextField
How to Create small TextField

Time:04-13

I want to reduce space between line and text with flutter. enter image description here

SizedBox(
                        width: 60.0,
                        child: TextField(
                          textAlign: TextAlign.center,
                          keyboardType: TextInputType.number,
                          style: TextStyle(color: Colors.black),
                          decoration: InputDecoration(
                            hintText: '125',
                          ),
                        ),
                      ),

CodePudding user response:

Instead of wrapping TextField inside SizedBox use constraints property of Input Decoration to give the TextField min or max height/width:

TextField(
    textAlign: TextAlign.center,
    keyboardType: TextInputType.number,
    style: TextStyle(color: Colors.black),
    decoration: InputDecoration(
      hintText: '125',
      isDense: true,
      constraints: BoxConstraints(
        maxWidth: 60
      )
    ),
  )

CodePudding user response:

Inside InputDecoration() set the contentPadding: EdgeInsets.zero. And set isDense: true

  • Related