Home > Mobile >  How to make clickable widget behind stack in flutter
How to make clickable widget behind stack in flutter

Time:07-13

i have two scaffold widget in the stack for some purposes .. and every scaffold has it's own contents . the second scaffold has transparent background colors so the first Scaffold is visible

Stack(
children[
   Scaffold(
   body: GestureDetector(
     onTap(){}
     child:  myBody()
      )
     )
  Scaffold(
   backGroundColor: Colors.transparent
   body: ListView.bulder(){....}
   )
 ]
)

the GestureDetector in first Scaffolddoes not work and that's because of the Scaffold stack

Note : i can't wrap the secand Scaffold with IgnorePointer because it has clickable ListView.bulder which gonna be ignoring any pointer too

How could i solve this ×_O

CodePudding user response:

You can set Gesture as outside of the stack and with this inner list click also works but when you put the first Scaffold body as a clickable it's not working because the second Scaffold overlay that.

GestureDetector(
         onTap(){}
         child:Stack(
    children[
       Scaffold(
       body:   myBody()
        
         )
      Scaffold(
       backGroundColor: Colors.transparent
       body: ListView.bulder(){....}
       )
     ]
    ))

CodePudding user response:

You need to add clickable widget at the end in your stack widget as below:

   Stack(
    children[
      firstWidget(),
      GestureDetector(
      onTap(){},
      child:  secondWidget()
      )
      
   ]
   )
  • Related