description

# matchingTarget property Null safety

Element matchingTarget
inherited

A pointer to the element whose CSS selector matched within which an event was fired. If this Event was not associated with any Event delegation, accessing this value will throw an UnsupportedError.

## Implementation

    Element get matchingTarget {
      if (_selector == null) {
        throw new UnsupportedError('Cannot call matchingTarget if this Event did'
            ' not arise as a result of event delegation.');
      }
      Element? currentTarget = this.currentTarget as Element?;
      Element? target = this.target as Element?;
      do {
        if (target!.matches(_selector!)) return target;
        target = target.parent;
      } while (target != null && target != currentTarget!.parent);
      throw new StateError('No selector matched for populating matchedTarget.');
    }