didvan-app/lib/utils/extension.dart

22 lines
492 B
Dart

import 'package:flutter/cupertino.dart';
extension NavigatorStateExtension on NavigatorState {
void pushNamedIfNotCurrent( String routeName, {Object? arguments} ) {
if (!isCurrent(routeName)) {
pushNamed( routeName, arguments: arguments );
}
}
bool isCurrent( String routeName ) {
bool isCurrent = false;
popUntil( (route) {
if (route.settings.name == routeName) {
isCurrent = true;
}
return true;
} );
return isCurrent;
}
}