I have two texts in a row, and one of them is way longer than the other one. I use spacer to give more spaces to one of the texts. If the text gets really long, it causes an overflow. How do I fix this?
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Spacer(),
Text(
"Longer text",
style: Theme.of(context).textTheme.bodyText1?.copyWith(
color:
Theme.of(context).colorScheme.white.withOpacity(0.85),
),
overflow: TextOverflow.fade,
softWrap: false,
textAlign: TextAlign.right,
),
const SizedBox(width: 10),
Text(
"smaller text",
style: Theme.of(context).textTheme.bodyText1?.copyWith(
color:
Theme.of(context).colorScheme.white.withOpacity(0.85),
),
overflow: TextOverflow.fade,
softWrap: false,
textAlign: TextAlign.left,
),
Spacer(),
],
),
2
Answers
wrap the text widget with the Expanded widget and give them spacing whatever you want
You need to use
RichText
like this: