jesusrp98 / expand_widget

Ability to easily expand and retract a widget collection or text
https://pub.dev/packages/expand_widget
GNU General Public License v3.0
45 stars 22 forks source link

ExpandText does not look correct inside Expand #1

Closed JamesMcIntosh closed 4 years ago

JamesMcIntosh commented 4 years ago

If the content is less than the width of the screen and the ExpandText is wrapped in an Expand then the text and expand arrow are centered in the middle of theExpandText.

I expected behaviour would be to start the text at the start and center the expand in the middle of the widget.

String content = "a\nb\nc\nd\ne\nf";
Column(children: [
  crossAxisAlignment: CrossAxisAlignment.start,
  Row(
    mainAxisAlignment: MainAxisAlignment.start,
    children: <Widget>[
      Expanded(
        child: ExpandText(
          content,
          maxLength: 4,
        ),
      ),
    ],
  ),
])

To make the children of the column expand to the width of the parent you need to add crossAxisAlignment: CrossAxisAlignment.stretch to the Column.

This could either be an optional default parameter as CrossAxisAlignment.stretch can cause a layout error if there is not a wrapping Expanded as the width becomes unbounded.

crossAxisAlignment: widget.fillWidth ? CrossAxisAlignment.center : CrossAxisAlignment.stretch