matches method

bool matches(
  1. String key
)

Returns true if the given key matches this element.

CensorElement element1 = CensorElement('key');
element1.matches('key'); // true
element1.matches('KEY'); // true

CensorElement element2 = CensorElement('key', caseSensitive: true);
element2.matches('key'); // true
element2.matches('KEY'); // false

Implementation

bool matches(String key) {
  if (caseSensitive) {
    return key == name;
  } else {
    return key.toLowerCase() == name.toLowerCase();
  }
}