Remove the trailing ICON and the space assigned for Trailing ICON from the Expansion Tile

2.7k views Asked by At

I am using a Expansion tile, but I do not want to have any trailing space occupied at the end of the widget. Event though i remove the trailing ICON with sized box, still the space for the ICON is occupied, I do not want the entire space for the content rather then the trailing ICON.

Below is my code:

ExpansionTile(
      initiallyExpanded: expanded,
      trailing: const SizedBox.shrink(),
      textColor: Colors.teal,
      collapsedTextColor: Colors.teal,
      title: SingleChildScrollView(
          scrollDirection: Axis.horizontal,
          child: Center(
              child: Text(title,
                  style: const TextStyle(
                    color: Colors.teal,
                  )))),
      iconColor: Colors.green,
      collapsedIconColor: Colors.teal,
      children: body)

Below is the image:

Expansion Tile

1

There are 1 answers

2
tomerpacific On

As per your desired behavior, you can just use a ListTile:

ListTile(
      trailing: const SizedBox.shrink(),
      textColor: Colors.teal,
      title: SingleChildScrollView(
          scrollDirection: Axis.horizontal,
          child: Center(
              child: Text(title,
                  style: const TextStyle(
                    color: Colors.teal,
                  )
               )
            )
      ),
      children: body)

Note: You might need to wrap the ListTile inside of an Expanded widget if it is within a Row/Column