4

So, the objective was very simple, wrap a bunch of text in a container. For that I followed this Flutter- wrapping text , but the new line created, has too much space between the previous line.

My code for the Container() with Text():

 description == ""
              ? SizedBox.shrink()
              : Container(
                  padding: const EdgeInsets.symmetric(horizontal: 10.0),
                  //width: MediaQuery.of(context).size.width * 0.8,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      new Text(
                        description,
                        textAlign: TextAlign.left,
                        style: TextStyle(fontSize: 18),
                      ),
                    ],
                  ),
                )

Small note: If any descripton is given to Parent widget, I just use a SizeBox.shrink() as an "empety widget".

How it current is, with too much space:

Current

How it should be:

Design Goal

I know that 1º image is bigger, but that's not why line spacing is greater 😄

1 Answer 1

6

As referred from here. You can adjust the line spacing by changing the height property inside the style. 1.0 seemed fine to me but you can try setting it to 0.8, 0.7.

  Container(
                  padding: const EdgeInsets.symmetric(horizontal: 10.0),
                  //width: MediaQuery.of(context).size.width * 0.8,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      new Text(
                        'You have pushed the button this many times: You have pushed the button this many times: You have pushed the button this many times: You have pushed the button this many times: You have pushed the button this many times: You have pushed the button this many times: You have pushed the button this many times:',
                        textAlign: TextAlign.left,
                        
                        style: TextStyle(fontSize: 18,   height: 1.0 ),
                      ),
                    ],
                  ),),
2
  • 4
    The shame with this is that it adjusts the text height generally, rather than just spacing between wrapped text lines, where the text is a single widget.
    – Scott
    Commented Aug 1, 2022 at 9:23
  • @Scott I do agree but there is no other way yet. Commented Aug 1, 2022 at 10:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.