observe method Null safety

void observe(
  1. Node target,
  2. {bool? childList,
  3. bool? attributes,
  4. bool? characterData,
  5. bool? subtree,
  6. bool? attributeOldValue,
  7. bool? characterDataOldValue,
  8. List<String>? attributeFilter}

Observes the target for the specified changes.

Some requirements for the optional parameters:

  • Either childList, attributes or characterData must be true.
  • If attributeOldValue is true then attributes must also be true.
  • If attributeFilter is specified then attributes must be true.
  • If characterDataOldValue is true then characterData must be true.


void observe(Node target,
    {bool? childList,
    bool? attributes,
    bool? characterData,
    bool? subtree,
    bool? attributeOldValue,
    bool? characterDataOldValue,
    List<String>? attributeFilter}) {
  // Parse options into map of known type.
  var parsedOptions = _createDict();

  // Override options passed in the map with named optional arguments.
  override(key, value) {
    if (value != null) _add(parsedOptions, key, value);

  override('childList', childList);
  override('attributes', attributes);
  override('characterData', characterData);
  override('subtree', subtree);
  override('attributeOldValue', attributeOldValue);
  override('characterDataOldValue', characterDataOldValue);
  if (attributeFilter != null) {
    override('attributeFilter', _fixupList(attributeFilter));

  _call(target, parsedOptions);