Flutter Textfield's height

Viewed 130

I'd like to reduce the "default" height of my TextField widget so that it matches my model (the bottom one, the top one is my emulator).

enter image description here

If wrap my TextField with a Container to put it a height, the TextField's height won't expand as I wanted as the number of line increases.

So I don't know what to do to reduce the default height.

TextField(
   keyboardType: TextInputType.multiline,
   maxLines: 5,
   minLines: 1,
   decoration: InputDecoration(
      hintText: "Saisir le message",
      contentPadding: const EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
      filled: true,
      fillColor: MC_lightGrey.withOpacity(0.5),
      border: new OutlineInputBorder(
         borderSide: BorderSide.none,
         borderRadius: const BorderRadius.all(
             const Radius.circular(10.0),
         ),
       ),
   ),
),
1 Answers

Try this code:

TextField(
   keyboardType: TextInputType.multiline,
   maxLines: 5,
   minLines: 1,
   decoration: InputDecoration(
      isDense: true,
      hintText: "Saisir le message",
      contentPadding: const EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
      filled: true,
      fillColor: MC_lightGrey.withOpacity(0.5),
      border: new OutlineInputBorder(
      borderSide: BorderSide.none,
      borderRadius: const BorderRadius.all(
        const Radius.circular(10.0),
      ),
    ),
  ),
),

Add isDense:true in InputDecoration.

Related