Expandable Listview - Flutter - ExpansionTile

Hello Guys, Today I am going to show you Expandable listview in flutter.
       We can make listview expansion by   ExpansionTile   widget which is provided by Flutter.

 

                                      
       
       Properties:
       backgroundColor: set the background color to the widget.
       
       children: To add child widget we will use this property
       
       initiallyExpanded: if we set true, child will expands default
       
       onExpansionChanged: To handle the expansion event
       
       title: set the header of the item.

 

ExpansionTile(
          key: PageStorageKey(this.widget.headerTitle),
          title: Container(
              width: double.infinity,

              child: Text("Header",style: TextStyle(fontSize: 18),),
          trailing: Icon(Icons.arrow_drop_down,size: 32,color: Colors.pink,),
          onExpansionChanged: (value){
            setState(() {
              isExpand=value;
            });
          },
          children: [
           Text("Child 1",style: TextStyle(fontSize: 18),),
            Text("Child 2",style: TextStyle(fontSize: 18),),
          ]
          )
          ),

 

We can handle the Expanstion listener with OnExpanstionChanged () function
  

Complete code you can find   rrtutors  github account.
          
Tags: Expandable Listview, Flutter, Listview




Related Questions View All