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.
Asked: 2022-07-31 11:00:00 +0000
Seen: 9 times
Last updated: Feb 16 '23