fbmobile/lib/core/services/navigation_service.dart
2021-02-02 15:33:23 +01:00

27 lines
877 B
Dart

import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import '../util/logger.dart';
class NavigationService {
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);
}
}