havong space between lines of richtext in flutter
To have spacing between lines of RichText in Flutter, you can use the TextSpan
widget along with the WidgetSpan
widget. Here's an example of how you can achieve this:
RichText(
text: TextSpan(
children: [
TextSpan(
text: 'First line of text',
),
WidgetSpan(
child: SizedBox(height: 10), // adjust the height as needed
),
TextSpan(
text: 'Second line of text',
),
],
),
)
In this example, the SizedBox
widget is used within a WidgetSpan
to create space between the lines of text. You can adjust the height
property of the SizedBox
widget to control the amount of spacing between the lines.
You can add more TextSpan
and WidgetSpan
widgets to create additional lines of text with spacing between them.
This approach allows you to have fine-grained control over the spacing between lines in your RichText
widget.