问题
The length of the texts on right is not fixed. I want to make the height of the line on left same as the texts area height.
Is there a way to align a widget to another widget like Android's RelativeLayout or ConstraintLayout in Flutter?
my code:
Container(
padding: EdgeInsets.fromLTRB(100, 0, 100, 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
color: Color(0xFFEEEEEE),
width: 4,
height: 80,
margin: EdgeInsets.only(right: 10),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
_content,
style: Theme.of(context).textTheme.headline4,
),
],
),
)
],
),
);
回答1:
Wrap your row into IntrinsicHeight
and get rid of the height property
IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
color: Color(0xFFEEEEEE),
width: 4,
margin: EdgeInsets.only(right: 10),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'a loong loong text with a lot of letters and characters',
style: Theme.of(context).textTheme.headline4,
),
],
),
)
],
),
),
来源:https://stackoverflow.com/questions/62753966/how-to-make-a-widgets-size-same-as-another-widget-in-flutter