I've got a row with 3 text widgets in it.
The middle text entry can span several lines, but the first two will be really small.
I'm wanting to have the first widget have the text at the top of the row and the 3rd widget to have the text at the bottom of the row.
It's basically something similar to this image
So basically the first widget would be the opening quote, then the 3rd the ending quote.
I can set a crossAxisAlignment on the row to start or end and that will move the quotes, but it'll move both of them.
At the moment I've got something like this:
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Text('"'),
),
Expanded(
child: Text(
entry.text,
style: style,
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
color: Colors.yellow,
child: Text(
'”',
textAlign: TextAlign.start,
),
),
],
);
but I'm not sure how to align the bottom quote to the bottom of the text, at the moment it sits at the top.
IntrinsicHeight is the widget you are looking for. It's working fine with that widget.
You can always do Column -> [Expanded(text), Expanded(Container(), Expanded(text)] and adjust the flex of the blank box as needed.
There's also Container (or Column/Row) -> Stack -> [Column(mainAxis start), Column(mainAxis end)].
Work smarter, not harder. IntrinsicHeight widget is computationally expensive and I would not recommend using it for this.
one idea would be to create a Stack, than wrap the
Text()
withPositioned
widget. position left quote totop:
andleft:
and right quote tobottom:
right:
. and wrap middle text withContainer
, calculate the remaining size fromMediaQuery.of(context).size.width - qouoteWidth*2
and set fixed size to container and position it at calculated coordinates.I am sure there are other solutions as well