fbmobile/lib/core/services/navigation_service.dart
2023-01-16 01:44:51 +01:00

29 lines
904 B
Dart

import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import '../util/logger.dart';
class NavigationService {
final GlobalKey<NavigatorState> _navigationKey = GlobalKey<NavigatorState>();
GlobalKey<NavigatorState> get navigationKey => _navigationKey;
final Logger logger = getLogger();
void pop() {
logger.d('NavigationService: pop');
_navigationKey.currentState!.pop();
}
Future<dynamic> navigateTo(String routeName, {dynamic arguments}) {
logger.d('NavigationService: navigateTo $routeName');
return _navigationKey.currentState!
.pushNamed(routeName, arguments: arguments);
}
Future<dynamic> navigateAndReplaceTo(String routeName, {dynamic arguments}) {
logger.d('NavigationService: navigateAndReplaceTo $routeName');
return _navigationKey.currentState!
.pushReplacementNamed(routeName, arguments: arguments);
}
}