skip to Main Content

How can I wrap multiple Widgets inside a Row to act like a single Widget?

widget order:
Column -> Row -> Widgets

Here is the snippet of my code:

Column(
        children: [
          Row(
            children: [
              Text(
                  'To prevent possible overflow, this particularly long text should be properly wrapped and formatted.'),
              Text(
                  'To prevent possible overflow, this particularly long text should be properly wrapped and formatted.'),
              Text(
                  'To prevent possible overflow, this particularly long text should be properly wrapped and formatted.'),
            ],
          ),
        ],
      ),

Current output:

enter image description here

Desired output:enter image description here

Any suggestions on how to solve this problem would be appreciated.

2

Answers


  1. Based on your desire UI, it will be a single Text widget. You can concatenate the string like $data1 $data2, it will merge the text.

    Column(
      children: [
       Text('yourText')
    

    If you have multiple textStyle, you can use RichText widget.

    Find more about String and RichText

    Login or Signup to reply.
  2. Hi i know this answer must be confusing but i find a way to do it

    String desc ="To prevent possible overflow, this particularly long text should be properly wrapped and formatted.";
    
    Column(
            children: [
              Row(
                children: [
                  Text(desc),
                  Text(desc),
                  Text(desc),
                ],
              ),
            ],
          ),
    

    creating a variable to the desc will automatically manage the overflow

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search