2021-02-02 14:33:23 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:logger/logger.dart';
|
|
|
|
|
|
|
|
import '../util/logger.dart';
|
|
|
|
|
|
|
|
class NavigationService {
|
2023-01-04 20:17:54 +00:00
|
|
|
final GlobalKey<NavigatorState> _navigationKey = GlobalKey<NavigatorState>();
|
2021-02-02 14:33:23 +00:00
|
|
|
|
|
|
|
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');
|
2023-01-16 00:44:34 +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');
|
2023-01-16 00:44:34 +00:00
|
|
|
return _navigationKey.currentState!
|
|
|
|
.pushReplacementNamed(routeName, arguments: arguments);
|
2021-02-02 14:33:23 +00:00
|
|
|
}
|
|
|
|
}
|