import 'package:flutter/material.dart'; extension NavigationExtensions on BuildContext { void navigateWithName(String routeName, {Object? arguments}) { Navigator.pushNamed(this, routeName, arguments: arguments); } Future navigateReplaceWithName(String routeName, {Object? arguments}) async { await Navigator.pushReplacementNamed(this, routeName, arguments: arguments); } void navigateReplaceWithNameUntilRoute(String routeName, {Object? arguments}) { Navigator.pushNamedAndRemoveUntil(this, routeName, (route) => false); } void pop() { Navigator.of(this).pop(); } void navigateTo(Widget page) { Navigator.push(this, MaterialPageRoute(builder: (context) => page)); } }