I have an ExpansionTile within my Drawer widget. When I expand this item, it automatically adds a divider line above and below. I want these divider lines permanently.
So I'd either like to know how to show the ExpansionTile's divider lines always (expanded and unexpanded), or I can add my own divider lines and tell the ExpansionTile to never show divider lines.
Is this possible? Thanks.
If you are using ExpantionTile inside the panel, you can provide trailing widget to it which will replace the arrow. Show activity on this post. I had a similar issue with ExpandablePanel, I created an ExpandableThemeData and set the hasIcon property to false.
You need to implement it in your code respectively: Create a new dart file called expansion_title_demo. dart inside the lib folder. In this screen, we will create a list with the help of a list view builder in which the expansion tile widget will be used and initialize the list data into the expansion tile widget.
Using an Expanded widget makes a child of a Row, Column, or Flex expand to fill the available space along the main axis (e.g., horizontally for a Row or vertically for a Column). If multiple children are expanded, the available space is divided among them according to the flex factor.
you can hide divider lines by wrapping the ExpansionTile widget in Theme Widget,
your code will look like this after you add Theme widget
Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child:ExpansionTile(
title:...,
children:[],
),
),
check this Github Issue
@RJB, I had the same issue, I resolved wrapping the ExpansionTile with a column, like this:
Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child: Column(
children: [
ExpansionTile(
title: Text(
'My title',
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
trailing: Icon(
_showContent
? Icons.expand_less_rounded
: Icons.expand_more_rounded,
),
onExpansionChanged: (bool expanded) {
setState(() => _showContent = expanded);
},
children: <Widget>[
Text('My content'),
],
),
const Divider(
color: Colors.amber,
thickness: 1,
height: 0,
)
],
),
);
I know it isn't pretty, but I could't find an Expansion component that I could personalize every aspect of its appearance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With