1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-30 09:47:31 +02:00
immich/mobile/lib/routing/duplicate_guard.dart
shenlong 27488ceb67
deps(mobile): flutter 3.16 (#6677)
* dep(mobile): update flutter and deps

* chore: dart analyzer

* chore: update flutter workflow version

* chore: dart format

* fix: gallery_viewer PopScope

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
2024-01-27 10:14:32 -06:00

20 lines
578 B
Dart

import 'package:auto_route/auto_route.dart';
import 'package:flutter/foundation.dart';
/// Guards against duplicate navigation to this route
class DuplicateGuard extends AutoRouteGuard {
DuplicateGuard();
@override
void onNavigation(NavigationResolver resolver, StackRouter router) async {
// Duplicate navigation
if (resolver.route.name == router.current.name) {
debugPrint(
'DuplicateGuard: Preventing duplicate route navigation for ${resolver.route.name}',
);
resolver.next(false);
} else {
resolver.next(true);
}
}
}