i added pop scope to my code to go to prev page when the back button on phone is pressed, but instead of going to prev page, it closed the app instead. I don’t want to close the app.
this is where i put my pop scope
@override
Widget build(BuildContext context) {
return PopScope(
canPop: true,
onPopInvoked: (bool didPop) async {
if (didPop) {
return;
}
Navigator.pop(context);
},
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
leading: Builder(
builder: (BuildContext context) {
return IconButton(
icon: const Icon(Icons.arrow_back),
color: Colors.black,
onPressed: () {
Navigator.pop(context);
},
);
},
),
title: Text(
'Pengajuan',
style: TextStyle(color: Colors.black),
),
),
//body
);
}`