navigateBack method
dynamic
navigateBack({
Implementation
navigateBack({int? index, dynamic data}) {
if (index != null) {
_pages.removeRange(index + 1, _pages.length);
Navigator.popUntil(navigatorKey.currentContext!, ModalRoute.withName(_pages.last.routeId));
if (_pages.length == 1) setNewRoute(_pages.last);
} else {
_pages.removeLast();
// Navigator.pop(navigatorKey.currentContext!, data);
// Navigator.popUntil(navigatorKey.currentContext!, ModalRoute.withName(_pages.last.routeId));
Navigator.pushReplacement(
navigatorKey.currentContext!,
PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) => _pages.last,
transitionsBuilder: (context, animation, secondaryAnimation, child) {
const begin = Offset(-1.0, 0.0); // Slide from left to right
const end = Offset.zero;
const curve = Curves.easeInOut;
final tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
final offsetAnimation = animation.drive(tween);
return SlideTransition(
position: offsetAnimation,
child: child,
);
},
),
);
}
}