fix(mobile): Prevents duplicate taps navigating to the same route twice (#1855)

This commit is contained in:
martyfuhry 2023-02-24 11:51:35 -05:00 committed by GitHub
parent 9323cc76d9
commit 4ed96cf1bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 553 additions and 224 deletions

View file

@ -0,0 +1,17 @@
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);
}
}
}