如何让
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);
},
),
但这对我不起作用
你尝试一下吗
Navigator.of(context).pop();