Home > Blockchain >  How to remove space between prefixIcon and texformfield text?
How to remove space between prefixIcon and texformfield text?

Time:01-24

enter image description here

How to remove space after prefix icon in TextFormField in flutter? I've already tried isCollapsed = true, isDense = true. And I have set my contentPadding: EdgeInsets.all(0). Using prefix instead of prefixIcon however solves my issue, but there is another problem. Prefix appears only on focus. How to solve my problem? I want to prefix(or prefixIcon) to appear always visible at the beginning. And TextFormField's text must be like continue of the prefix.

CodePudding user response:

Try with this

TextFormField(
            decoration: const InputDecoration(
            prefixIcon: Text("118"),
            prefixIconConstraints: BoxConstraints(maxWidth: 40)),
)

CodePudding user response:

check the code below: It works perfectly:

TextField(
    decoration: InputDecoration(
      // choose any icon of your choice here
      prefixIcon: Icon(Icons.person),
      // set the prefix icon constraints
      prefixIconConstraints: BoxConstraints(
        minWidth: 25,
        minHeight: 25,
      ),
    ),
  ),
  •  Tags:  
  • Related