import 'package:flutter/material.dart'; class NavigationService { // static NavigationService instance = NavigationService(); GlobalKey? navigatorKey; NavigationService() { navigatorKey = GlobalKey(); } Future? navigateToReplacement(String _routeName) { return navigatorKey!.currentState!.pushReplacementNamed(_routeName); } Future? navigateTo(String _routeName) { return navigatorKey!.currentState!.pushNamed(_routeName); } Future? navigateToRoute(MaterialPageRoute _route) { return navigatorKey!.currentState!.push(_route); } // Manually Call Function goBack() { return navigatorKey!.currentState!.pop(); } }