How to remove the margin added to the label in TextField that has prefixIcon when receiving focus?

Viewed 67

When the TextDield receives focus the label receives a margin in relation to the prefixIcon.

Current

inserir a descrição da imagem aqui

Objective:

inserir a descrição da imagem aqui


Container(
  padding: EdgeInsets.all(10),
  child: TextFormField(
    keyboardType: TextInputType.number,
    textInputAction: TextInputAction.continueAction,
    style: TextStyle(fontSize: 20),
    decoration: InputDecoration(
      alignLabelWithHint: true,
      prefixIcon: Icon(Icons.device_thermostat),
      labelText: "Temperature",
      border: OutlineInputBorder(),
      hintText: "Enter  temperature",
    ),
  ),
)
1 Answers

Try replacing prefixIcon: Icon(Icons.device_thermostat), with prefix: Icon(Icons.device_thermostat),. Here is an example on DartPad with one field using prefixIcon and a second using prefix.

Related