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.
		
		
		
		
		
			
		
			
				
	
	
		
			55 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
import 'package:flutter/material.dart';
 | 
						|
import 'package:hmg_patient_app_new/features/authentication/widgets/otp_verification_screen.dart';
 | 
						|
 | 
						|
class NavigationService {
 | 
						|
  final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
 | 
						|
 | 
						|
  BuildContext? get context => navigatorKey.currentContext;
 | 
						|
 | 
						|
  Future<T?> push<T>(Route<T> route) {
 | 
						|
    return navigatorKey.currentState!.push(route);
 | 
						|
  }
 | 
						|
 | 
						|
  void pop<T extends Object?>([T? result]) {
 | 
						|
    navigatorKey.currentState!.pop(result);
 | 
						|
  }
 | 
						|
 | 
						|
  void popUntilNamed(String routeName) {
 | 
						|
    navigatorKey.currentState?.popUntil(ModalRoute.withName(routeName));
 | 
						|
  }
 | 
						|
 | 
						|
  void pushAndReplace(String routeName) {
 | 
						|
    navigatorKey.currentState?.pushReplacementNamed(routeName);
 | 
						|
  }
 | 
						|
 | 
						|
  Future<T?> pushToOtpScreen<T>({
 | 
						|
    required String phoneNumber,
 | 
						|
    required Function(int code) checkActivationCode,
 | 
						|
    required Function(String phoneNumber) onResendOTPPressed,
 | 
						|
  }) {
 | 
						|
    return navigatorKey.currentState!.push(
 | 
						|
      MaterialPageRoute(
 | 
						|
        builder: (_) => OTPVerificationScreen(
 | 
						|
          phoneNumber: phoneNumber,
 | 
						|
          checkActivationCode: checkActivationCode,
 | 
						|
          onResendOTPPressed: onResendOTPPressed,
 | 
						|
        ),
 | 
						|
      ),
 | 
						|
    );
 | 
						|
  }
 | 
						|
 | 
						|
  Future<T?> pushPage<T>({
 | 
						|
    required Widget page,
 | 
						|
    bool fullscreenDialog = false,
 | 
						|
    bool maintainState = true,
 | 
						|
  }) {
 | 
						|
    return navigatorKey.currentState!.push<T>(
 | 
						|
      MaterialPageRoute(
 | 
						|
        builder: (_) => page,
 | 
						|
        fullscreenDialog: fullscreenDialog,
 | 
						|
        maintainState: maintainState,
 | 
						|
      ),
 | 
						|
    );
 | 
						|
  }
 | 
						|
}
 |