Hard to explain in the title but I want to have two text widgets within a wrap widget so that they don’t overflow but I also want them placed one after another like a span so that they’re on the same line and it reads as a single sentence. I want to be able to colour one specific word a different colour to the rest of the sentence.
I understand why it’s happening. The text widget is too long to fit in the remaining space of the row, so it’s wrapping to the new line.
Is there anyway to make it so that it can break the text widget in appropriate places and use the entire row or will I have to make each word an individual text widget so it does it?
Wrap(
children: [
Text("This is the first part ",
style: TextStyle(
color: WorkoutTheme.textPrimaryWhite,
fontSize: WorkoutTheme.h1Size,
fontWeight: FontWeight.w600,
height: 1)),
Text("this is second",
style: TextStyle(
color: Colors.red, fontSize: WorkoutTheme.h1Size, fontWeight: FontWeight.w600, height: 1)),
Text(" this wraps to a new line",
overflow: TextOverflow.clip,
style: TextStyle(
color: WorkoutTheme.textPrimaryWhite,
fontSize: WorkoutTheme.h1Size,
fontWeight: FontWeight.w600,
height: 1)),
],
)
1
You can use RichText Widget.
You can follow this link to do so.
RichText