15 lines
506 B
Dart
15 lines
506 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
/// Navigates to [location] after closing open dialogs and side panels only.
|
|
void goAndDismissOverlays(BuildContext context, String location) {
|
|
final navigator = Navigator.of(context, rootNavigator: true);
|
|
|
|
// Close overlay routes (side panels, dialogs) without resetting the page stack.
|
|
navigator.popUntil((route) => route.isFirst || route is! PopupRoute);
|
|
|
|
if (context.mounted) {
|
|
context.go(location);
|
|
}
|
|
}
|