You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App_New/lib/extensions/route_extensions.dart

28 lines
827 B
Dart

import 'package:flutter/material.dart';
extension NavigationExtensions on BuildContext {
void navigateWithName(String routeName, {Object? arguments}) {
Navigator.pushNamed(this, routeName, arguments: arguments);
}
Future<void> 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));
}
void popUntilNamed(String routeName) {
Navigator.popUntil(this, ModalRoute.withName(routeName));
}
}