Flutter : how to remove leading,trailing spaces in ExpansionTileCard

129 Views Asked by At

In my android application I used flutter ExpansionTileCard to list a list of items with its child elements.My problem is the the leading and trailing area in ExpansionTileCard taking to much space and hence the title area get minimum area to display the content, also i don't have anything to display on leading.Also how can i change the trailing icon along with minimizing the trailing space.How should i customize ExpansionTileCard to do so??

note : I tried to apply SizedBox() on trailing and applied transform property on title but nothing worked.

requirements :

1.Remove leading space completely. 2.Shorten the trailing area and change the trailing icon 3. Use the remaining area completely for the title section

pubspec.yml :

expansion_tile_card: ^2.0.0

Below is my code :

ListView.builder(
            itemCount: taskList!.length,
            itemBuilder: (context, index) {
              return Card(
                elevation: 6,
                margin: const EdgeInsets.all(2),
                child: ExpansionTileCard(
                    baseColor: index % 2 == 0 ? shade10 : shade20,
                    leading: SizedBox(),
                    title: Container(
                      color: Colors.yellow,
                      transform: Matrix4.translationValues(-70, 0, 0),
                      child: Text(taskList![index]['task']['heading'],
                        maxLines: 1,
                      ),
                    ),
                    subtitle: Container(
                      color: Colors.orange,
                      transform: Matrix4.translationValues(-50, 0, 0),
                      child: Row(
                        children: [
                          Text(dateFormat.format(dateFormat.parse(taskList![index]['task']['date']))),
                          SizedBox(width: 20,),
                          Text(dateFormat.format(dateFormat.parse(taskList![index]['task']['user']))),
                        ],
                      ),
                    ),
                    children: <Widget>[
                      Divider(
                        thickness: 1.0,
                        height: 1.0,
                      ),
                      Align(
                        alignment: Alignment.centerLeft,
                        child: Padding(
                          padding: const EdgeInsets.symmetric(
                            horizontal: 8.0,
                            vertical: 4.0,
                          ),
                          child: Text(taskList![index]['task']['message'],
                            style: Theme.of(context)
                                .textTheme
                                .bodyText2!
                                .copyWith(fontSize: 16),
                          ),
                        ),
                      ),
                      SingleChildScrollView(
                        scrollDirection: Axis.horizontal,
                        child: ButtonBar(
                          alignment: MainAxisAlignment.spaceAround,
                          buttonHeight: 40.0,
                          buttonMinWidth: 90.0,
                          children: <Widget>[
                            ElevatedButton(
                              onPressed: () {
                                
                              },
                              child: Text(''),
                            ),
                            ElevatedButton(
                              onPressed: () {
                                
                              },
                              child: Text(''),
                            ),
                            ElevatedButton(
                              onPressed: () {
                                
                              },
                              child: Text(''),
                            ),
                            ElevatedButton(
                              onPressed: () {
                                
                              },
                              child: Text(''),
                            ),
                          ],
                        ),
                      ),
                    ],
                    trailing: const SizedBox(),
                  ),
              );
            },);
0

There are 0 best solutions below