I'm working on a FLutter application and found a strange issue.
I have got this widget:
@override
Widget build(BuildContext context) {
var route = ModalRoute.of(context)!.settings.name;
return IconButton(
icon: const Icon(
UniconsLine.previous,
shadows: [
BoxShadow(
blurRadius: 15.0,
color: Colors.black,
),
BoxShadow(
blurRadius: 15.0,
color: mainBgColor,
)
],
size: 40,
),
onPressed: () {
print(route);
Navigator.pop(context);
},
);
}
What I'm trying to do is pop the content and go back to the previous page. Somehow, all I got is a blank page. The route is "/" here. On the other pages, the route is just null. When I'm using the Android navigation button it routes to the previous page.
What is the solution for this?
pushNamedAndRemoveUntil? maybe that caused the route to be null. because it will remove all the previous routes