matches method

  1. @useResult
bool matches(
  1. Pattern pattern
)

Returns true if this matches pattern.

'abc'.matches('abC'); // true

'ab'.matches('abc'); // false

'abcabc'.matches('abc'); // false

Implementation

@useResult bool matches(Pattern pattern) => switch(pattern.matchAsPrefix(this)) {
  final match? when match.start == 0 && match.end == length => true,
  _ => false,
};