Ask Your Question
3

How can I move a non-Text Widget to the next line within a row, but ensure it starts from the far left of its parent widget?

asked 2022-07-31 11:00:00 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-02-16 20:00:00 +0000

david gravatar image

You can achieve this by using a combination of widgets such as Row, Expanded, SizedBox, and IntrinsicWidth.

Here's an example:

Row(
  children: [
    // Your first widget here
    Expanded(
      child: SizedBox(), // Use a SizedBox to insert space between widgets
    ),
    IntrinsicWidth(
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start, // Align children to the top
        children: [
          // Your non-Text widget here
        ],
      ),
    ),
  ],
)

By wrapping the non-Text widget in an IntrinsicWidth widget, you ensure that it takes up the minimum amount of width required to display its contents. The Expanded widget at the beginning of the Row then takes up all the remaining space and pushes the IntrinsicWidth to start from the left. The SizedBox inside Expanded is used to insert a space between widgets. Finally, the crossAxisAlignment property is set to CrossAxisAlignment.start to ensure that the non-Text widget aligns to the top of the row.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-07-31 11:00:00 +0000

Seen: 9 times

Last updated: Feb 16 '23