DavBfr/flutter_pref

Propagate visualDensity and dense for ListTile

Closed this issue · 2 comments

Is there any way to propagate the visualDensity and dense attribute of ListTile from 'PrefSwitch' and 'PrefRadio' and whatever other widget uses ListTile?

The purpose is to make the vertical padding smaller.

For reference: https://stackoverflow.com/questions/55265313/remove-space-top-and-bottom-listtile-flutter/63504719#63504719

Thank you for your awesome work!

You should change the theme:
ListTileTheme.dense
and
ThemeData.visualDensity

Thank you, it does what I need.

For anyone who needs the same thing, my structure looks like this:

Theme(
    data: Theme.of(context).copyWith(visualDensity: VisualDensity.standard),
    child: ListTileTheme(
      dense: true,
      child: PrefPage(
        children: [

You can also apply the 2 widgets to a child of PrefPage, for example PrefRadio.