2021-02-02 14:33:23 +00:00
|
|
|
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');
|
2021-11-29 23:44:22 +00:00
|
|
|
_navigationKey.currentState!.pop();
|
2021-02-02 14:33:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<dynamic> navigateTo(String routeName, {dynamic arguments}) {
|
|
|
|
logger.d('NavigationService: navigateTo $routeName');
|
2021-11-29 23:44:22 +00:00
|
|
|
return _navigationKey.currentState!.pushNamed(routeName, arguments: arguments);
|
2021-02-02 14:33:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<dynamic> navigateAndReplaceTo(String routeName, {dynamic arguments}) {
|
|
|
|
logger.d('NavigationService: navigateAndReplaceTo $routeName');
|
2021-11-29 23:44:22 +00:00
|
|
|
return _navigationKey.currentState!.pushReplacementNamed(routeName, arguments: arguments);
|
2021-02-02 14:33:23 +00:00
|
|
|
}
|
|
|
|
}
|