Reputation: 150
I used RichText to do this earlier(Flutter- wrapping text) but now I need to use a custom Text Widget (which a library returns) with a inbuilt Text widget but unfortunately the TextSpan used with RichText accepts only TextSpan as children and not any other type of Widgets.
When using row this happens D: which i dont need
and when i use a Wrap Widget this happens which i dont need either
Upvotes: 2
Views: 1418
Reputation: 87
Wrap(
children: [
...splitToManyWidgets(text1),
...splitToManyWidgets(text2),
],
),
///////
List<Widget> splitToManyWidgets(String str) {
List<Widget> result = [];
List<String> list = str.split(" ");
for (var element in list) {
result.add(
Text("$element ")
);
}
return result;
}
Upvotes: 1
Reputation: 300
try this way,
RichText(text: TextSpan(
children: [
WidgetSpan(child: Container()),
TextSpan(text: 'hs dhjfb jkwbfkjw hkjfhkwjk jwjbjfwkj wb')
]
))
Upvotes: 2