2

I want to achieve this layout enter image description here

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 enter image description here

and when i use a Wrap Widget this happens which i dont need either enter image description here

codeboi
  • 150
  • 1
  • 9

2 Answers2

2

try this way,

  RichText(text: TextSpan(
                 children: [
                      WidgetSpan(child: Container()),
                      TextSpan(text: 'hs dhjfb jkwbfkjw hkjfhkwjk jwjbjfwkj wb')
                           ]
                        ))
Sadhik
  • 304
  • 1
  • 6
1
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;
  }
Erez
  • 87
  • 1
  • 4