Expandable ListView in Flutter

Save

In this blog, We are going to learn how we can create an expandable listview in our Flutter applications. Expandable ListView is a type of list view that is used to show multiple types of data based on category and subcategory. Expandable list view is used to expand or collapse the view in list items In a flutter app. We can easily make our own Expandable ListView using the ExpansionTile widget.

You may also check our Flutter app development services.

Expansions Tile Widget :

ExpansionTiles is used to produce two-level or multi-level lists in the app. ExpansionTiles widget is a detailed tile. It is like a ListTile widget which will expand by tapping the tile. We can display some detailed information on the list with ExpansionTiles.

Properties of the Expansions Tile :

Code For Expandable listview:

Here’s the complete code ->

main.dart file

datamodel.dart file ->

Outputs:

Conclusion

In this blog, we have discussed how we can create an expandable listview on our app screen. I hope it will help you out in understanding and get a brief idea about it.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


4 comments

  • Safaa
    Thanks for this tutorial. However, it needs
    import ‘package:expanded_listview_demo/subCategory.dart’;

    which is not available in the tutorial. Could You please provide it.

    • Mohit Kumar (Moderator)
      Hi Safaa,This is a simple widget to show the details of a subcategory.
      import ‘package:flutter/material.dart’;
      class SubCategory extends StatelessWidget {
        String? name;
        SubCategory(this.name,{Key? key}) : super(key: key);
        @override
        Widget build(BuildContext context) {
          return Scaffold(
            appBar: AppBar(title: Text(name ??”),),
            body: Center(child: Text(
              “This is $name category screen”
            ),)
          );
        }
      }
       
  • BurhanBey
    Hello,
    I have a simple table in my sqlite database with the following fields:
    id, title, category

    1, “Title 1”, “Video”
    2, “Title 2”, “Audio”
    3, “Title 3, “Video”

    I want to group those with the same category and get a dataList like in your example. How can I do this?

    • Mohit Kumar (Moderator)
      HiBurhanBey,

      You need to fetch the data from the database and create a data model according to your need. After then you create the Expansions Tile according to you data.

  • css.php

    We've bought a Shopware Extension which is a hybrid App, which we can now offer in the Google Play Store and the IOS App Store. I'am still impressed how fast and how sharp the support team leads us through every process of the App-Store clarification. Very fast and useful response.

    Markus Walter

    Markus Walter

    Founder, Das Apartment Living

    Talk to Sales

    Global

    Live Chat
    Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home