0

Here is the gesture Detector in which I am using setstate inside
gesture detector and I've applied check on expansion tile:

Future<void> showModel(BuildContext context) {
bool openList=false;
return showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
  builder: (BuildContext context) {
    return Container(
      child:ListView(
        shrinkWrap: true,
        children: [
              GestureDetector(
               onTap: (){
                setState(() {
                 openList=true;
                });
               },
                child: Image.asset('assets/icons/diirection.png', 
                height: Get.height * 0.05)),
          
        openList==false? ExpansionTile(
          tilePadding: EdgeInsets.all(0),
        title:itemRow(),
        children: [
          itemDetails()
        ],
        ):Text('data'),
       
        ]
      ),
    );
  
  },
);

}

and here the widget which I want to change on tap.

openList==false? ExpansionTile(
          tilePadding: EdgeInsets.all(0),
        title:itemRow(),
        children: [
          itemDetails()
        ],
        ):Text('data'),

1 Answers1

0
Future<void> showModel(BuildContext context) {
bool openList=false;

on the second line here, every time the build method is called, that is, as long as the widget exists, openList is being set to false. you should take bool openLists = false; outside your build method.

Miro
  • 364
  • 1
  • 12