withoutPrefix method

String withoutPrefix(
  1. Pattern prefix
)

Returns a copy of this with prefix removed if it is present.

If this does not start with prefix, returns this.

Example:

var string = 'abc';
string.withoutPrefix('ab'); // 'c'
string.withoutPrefix('z'); // 'abc'

Implementation

String withoutPrefix(Pattern prefix) => this.startsWith(prefix)
    ? this.substring(prefix.allMatches(this).first.end)
    : this;