withParameters method
Returns a copy of this instance with parameters multiLine and caseSensitive.
If this instance already have the same parameters returns this instance.
If this instance hasErrors and throwCompilationErrors is true,
throws a StateError. Otherwise the copy keeps the compilation errors
(hasErrors, errorWords, ...), and getWordPattern throws a
StateError for the words with errors, like 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, _errors);
}