Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Navigator.pop(context) isn't working in GestureDetector

How to make Navigator.pop(context) work in GestureDetector?
I think the problem with SingleChildScrollView, but I don’t understand how to fix it.

 Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: greyGood,
      body: SizedBox(
        width: double.infinity,
        height: double.infinity,
        child: Stack(
          children: [
            SizedBox(
              height: 350,
              width: double.infinity,
              child: Image.asset(
                widget.photo,
                fit: BoxFit.cover,
              ),
            ),
            SafeArea(
              child: Padding(
                padding: const EdgeInsets.only(left: 10),
                child: IconButton(
                  icon: Icon(Icons.arrow_back_ios_new_rounded),
                  onPressed: () {
                    Navigator.of(context).pop;
                  },
                ),
              ),
            ),
            Positioned(
              top: 0,
              left: 0,
              right: 0,
              bottom: 0,
              child: SingleChildScrollView(
                child: Column(

I tried use

setState(() {
          Navigator.pop(context);
});

and tried to replace with

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

IconButton(
     icon: Icon(Icons.arrow_back_ios_new_rounded),
     onPressed: () {
     Navigator.pop(context);
  },
),

but it isn’t worked for me

>Solution :

Move SafeArea widget after Positioned in list. The problem is that the Positioned is over SafeArea and gestures was not recognized.

Also instead of pop;, you have to use pop();

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading