Home > Mobile >  Space between background color of text on each line?
Space between background color of text on each line?

Time:09-27

I have set the background color of the Text widget, but if there are multiple line then the color is connected between lines. I want color to have space between each line of the text.

Text with background color but with space between each line

CodePudding user response:

you to have spaces within lines, you can separate each text to its own widget and add them to a column where you can set a space between theme with sizedBox :

        Column(
          children: <Widget>[
            Text("Ask me"),
            SizedBox(height: 20),
            Text("Anything"),
          ],
        ),

there are also more solutions, you can use RichText widget :

    Text.rich(TextSpan(children: [
          TextSpan(text: "Ask me"),
          TextSpan("\n"),
          TextSpan(text: "Anything"),
        ])),

CodePudding user response:

I assume you are using paint() as text background.

If so you can try text line height, it might fix your issue.

  • Related