Reputation: 126
In my project, I use autogeneration of routes with auto_route
package. I just started working with this package, so I don't understand what method can be used to return to the previous screen. I have this code for my TextButton and I need to implement onPressed method.
TextButton(
onPressed: () {
//AutoRoute.of(context).popRoute();
},
child: const Text(
'Close',
style: TextStyle(color: Colors.black),
),
),
Upvotes: 0
Views: 775
Reputation: 3552
The documentation says this on pub.dev:
context.router.pop();
It's a context extension, so this should also work:
AutoRouter.of(context).pop();
Also this helper method should work:
context.back();
Upvotes: 1