midi
midi

Reputation: 4038

After flutter Upgrade Listtile leading content does not match parent anymore

After doing flutter upgrade yesterday the content of ListTile leading (especially the height) does not match parent anymore. I have a overflow in height now. Width is working as expected. As you can see in the picture there is still space below the leading widget. Does anyone know how to fix this?

Or is there a way to downgrade the flutter version?

  Widget _listTile(){
return ListTile(
  contentPadding: EdgeInsets.fromLTRB(3.0, 1.0, 0.0, 1.0),
  dense: true,

  leading: Column(
    children: <Widget>[
      _leadingButton(),
      _leadingProgress
    ],
  ),
  title: _textSubtitle(subtitle),
  subtitle: _textSubtitle(subtitle),

);

}

enter image description here

Upvotes: 0

Views: 430

Answers (1)

rmtmckenzie
rmtmckenzie

Reputation: 40423

I believe the change that has caused this is [this one][1]: https://github.com/flutter/flutter/commit/0e2eeb5a485aaccdab7007ad9b90fd8120e77983#diff-53f33273ae4e7462729c5f4b7394428b. If you read the code, it says it was doing an update to adhere to the material spec which means a constraint on the size of the widget, so there's a very good chance it won't change back to how it was. How you were using it was technically against the material spec.

But rather than trying to downgrade flutter, you could simply create your own widget that does the same thing - you don't need to use a ListTile.

Something like this would probably do:

class MyListTile extends StatelessWidget {
  final Widget leading;
  final Widget title;
  final Widget subtitle;
  final EdgeInsets padding;

  MyListTile({@required this.leading, @required this.title, @required this.subtitle, this.padding});

  @override
  void build(BuildContext context) {
    return Padding(
      padding: padding ?? EdgeInsets.zero,
      child: Row(
        children: [
          leading,
          Expanded(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                title,
                subtitle,
              ],
            ),
          ),
        ],
      ),
    );
  }
}

Full disclosure though - I haven't run that code or even put it in an IDE so it may have issues, but that should illustrate the basics of what you're trying to do there. You'd probably want to wrap things in padding (most likely at least the leading widget) as needed to get the spacing you currently have.

Upvotes: 1

Related Questions