Navigator.pop(context) 在 GestureDetector 中不起作用

问题描述 投票:0回答:1

如何让

Navigator.pop(context)
GestureDetector
中工作? 我认为问题出在
SingleChildScrollView
,但我不明白如何解决它。

 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(

我尝试过使用

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

并尝试替换为

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

但这对我不起作用

flutter dart
1个回答
0
投票

你尝试一下吗

Navigator.of(context).pop();

© www.soinside.com 2019 - 2024. All rights reserved.