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.
28 lines
824 B
Dart
28 lines
824 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
|
import 'package:mohem_flutter_app/main.dart';
|
|
|
|
|
|
void setupLocator() {
|
|
print("GetIt Registered :::::");
|
|
locator.registerLazySingleton(() => NavigationService());
|
|
}
|
|
|
|
class NavigationService {
|
|
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
|
|
|
|
static Future<dynamic> navigateTo(String routeName) {
|
|
var key = locator<NavigationService>().navigatorKey;
|
|
return key.currentState!.pushNamed(routeName);
|
|
}
|
|
|
|
static Future<dynamic> navigateToPage(Widget page) {
|
|
var key = locator<NavigationService>().navigatorKey;
|
|
var pageRoute = MaterialPageRoute(builder: (context) => page);
|
|
return Navigator.push(key.currentContext!, pageRoute);
|
|
}
|
|
}
|
|
|
|
|