How to remove the gap above and below the text on flutter

1,768

Solution 1

The only way I could find so far is to reduce height property, the problem though is that it reduces the gap above only. So in your case, you could try to set it for hello text to the minimum:

Text(
   '123',
    style: TextStyle(fontSize: 60.0),
),
Text(
   'hello',
    style: TextStyle(fontSize: 10.0, height: 0.1),
),

Solution 2

Use Stack widget to align your text widgets

Stack(
      children: <Widget>[
        Text(
          '123',
          style: TextStyle(fontSize: 60.0),
        ),
        Positioned(
          child: Text('Hello'),
          bottom: 0.0,
          left: 35.0,
        )
      ],
    ),

Hope it helps!

Share:
1,768
Ateyib Abdulkadir
Author by

Ateyib Abdulkadir

Updated on December 08, 2022

Comments

  • Ateyib Abdulkadir
    Ateyib Abdulkadir over 1 year

    I am trying to put the text "Hello" right below the "123", but the bigger the text is, the bigger the gap. How do I remove the gap??? Flutter images are added below.

    enter image description here

    enter image description here