Closed as not planned
Description
Sorry if this issue already exists, but I couldn't find anything about this is the search.
I think it would be very useful if we could negate a if-case
statement. In my code I wanted to execute something only if a pattern match happened, but I couldn't, so the only other option was using an else
with an empty if-case
body, which looked very ugly.
What I wanted:
// test case for when a particular go_router route is not the current route:
final matches = router.routerDelegate.currentConfiguration.matches;
if (matches case! [RouteMatchBase(matchedLocation: '/home'), ImperativeRouteMatch(matchedLocation: '/details')]) {
fail('No route found');
}
What I can do now:
final matches = router.routerDelegate.currentConfiguration.matches;
if (matches case [RouteMatchBase(matchedLocation: '/home'), ImperativeRouteMatch(matchedLocation: '/details')]) {
// Empty body because I can't negate the if-case
} else {
fail('No route found');
}