shouldGuard method
Returns true if the guard pattern matches the given path.
Implementation
bool shouldGuard(String path) {
//todo logging
developer.log("path: $path", name: 'AppNavigationGuard::shouldGuard');
RegExp? reExclude, reGuard;
if (guardExcludePattern is String && (guardExcludePattern as String).isNotEmpty) {
reExclude = tryCastToRegExp(guardExcludePattern!);
}
if (guardPattern is String && (guardPattern as String).isNotEmpty) {
reGuard = tryCastToRegExp(guardPattern);
}
if (reExclude == null || reGuard == null) {
return false;
}
if (!reExclude.hasMatch(path)) {
return reGuard.hasMatch(path);
} else {
return false;
}
}