wildcardMatch method
Returns true if this string matches the pattern with wildcards.
pattern may contain:
*matches zero or more characters?matches exactly one character- Other characters match literally. Matching is case-sensitive.
pattern must not be null. Empty pattern matches only empty string.
Example:
'hello.txt'.wildcardMatch('*.txt'); // true
'file'.wildcardMatch('f?le'); // true
'ab'.wildcardMatch('a*b'); // true
Implementation
@useResult
bool wildcardMatch(String pattern) {
if (pattern.isEmpty) return isEmpty;
return _wildcardMatchImpl(
string: this,
stringIndex: 0,
pattern: pattern,
patternIndex: 0,
);
}