codeboi
codeboi

Reputation: 150

Break and wrap widget to next line in a row but start from extreme left of parent widget

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

Upvotes: 2

Views: 1418

Answers (2)

Erez
Erez

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

Sadhik
Sadhik

Reputation: 300

try this way,

  RichText(text: TextSpan(
                 children: [
                      WidgetSpan(child: Container()),
                      TextSpan(text: 'hs dhjfb jkwbfkjw hkjfhkwjk jwjbjfwkj wb')
                           ]
                        ))

Upvotes: 2

Related Questions