withParameters method

RegExpDialect withParameters({
  1. bool? multiLine = false,
  2. bool? caseSensitive = true,
  3. bool throwCompilationErrors = true,
})

Returns a copy of this instance with parameters multiLine and caseSensitive. If this instance already have the same parameters returns this instance.

Implementation

RegExpDialect withParameters(
    {bool? multiLine = false,
    bool? caseSensitive = true,
    bool throwCompilationErrors = true}) {
  multiLine ??= this.multiLine;
  caseSensitive ??= this.caseSensitive;

  if (hasErrors && throwCompilationErrors) {
    throw StateError(
        "Can't use a dialect with errors. Words with errors: ${errorWords.join(', ')}");
  }

  if (this.multiLine == multiLine && this.caseSensitive == caseSensitive) {
    return this;
  }

  return RegExpDialect._(_dialect, multiLine, caseSensitive);
}