1

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

tomerpacific
  • 4,704
  • 13
  • 34
  • 52
Aravind
  • 1,145
  • 6
  • 18
  • 44

1 Answers1

0

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

tomerpacific
  • 4,704
  • 13
  • 34
  • 52
  • , I need an expansion tile , because I have more content to display when it is expanded. – Aravind Apr 05 '22 at 00:11
  • 1
    As per the [expansion tile documentation](https://api.flutter.dev/flutter/material/ExpansionTile-class.html) it comes built in with the arrow. You can't have it both ways. Meaning, have a tile that will expand when more content is available and not have the arrow. You can create your own ListTile with your desired behavior. – tomerpacific Apr 05 '22 at 06:11