Home > Net >  How to stop both widgets in a stack from responding to touch
How to stop both widgets in a stack from responding to touch

Time:06-18

I have a Stack Widget which contains a map (covering the whole page) and a listview at the bottom and above the map. But when you swipe the listview, the map also moves. How do I stop the map from moving as well? The Listview is in front of the Map so I am unsure as to why the map also responds to me moving the listview.

Stack(
   children <Widget> [
      Map(),
      ListView( ... ),
   ]
)

Thank you

CodePudding user response:

Use the IgnorePointer widget to wrap the map

IgnorePointer(ignoring: false, ...)

and adjust this attribute by changing the bool value of ignoring:

CodePudding user response:

Use absorb pointer where you don't wish to pass the gesture to the map. In the stack use this heirarchy

Stack(
 children: [
  Map(),
  Positioned(
    bottom :0,
    child: AbsorbPointer(//this will absorb the pointer from going to the map
     child : Container(
       height: 300 // edit this to the required height
     width: MediaQuery.of(context).size.width
     )
   )
  ),
 // Listview here
]
)
  • Related