updateWith method Null safety

void updateWith(
  1. {required SemanticsConfiguration? config,
  2. List<SemanticsNode>? childrenInInversePaintOrder}
)

Reconfigures the properties of this object to describe the configuration provided in the config argument and the children listed in the childrenInInversePaintOrder argument.

The arguments may be null; this represents an empty configuration (all values at their defaults, no children).

No reference is kept to the SemanticsConfiguration object, but the child list is used as-is and should therefore not be changed after this call.

Implementation

void updateWith({
  required SemanticsConfiguration? config,
  List<SemanticsNode>? childrenInInversePaintOrder,
}) {
  config ??= _kEmptyConfig;
  if (_isDifferentFromCurrentSemanticAnnotation(config)) {
    _markDirty();
  }

  assert(
    config.platformViewId == null || childrenInInversePaintOrder == null || childrenInInversePaintOrder.isEmpty,
    'SemanticsNodes with children must not specify a platformViewId.',
  );

  _attributedLabel = config.attributedLabel;
  _attributedValue = config.attributedValue;
  _attributedIncreasedValue = config.attributedIncreasedValue;
  _attributedDecreasedValue = config.attributedDecreasedValue;
  _attributedHint = config.attributedHint;
  _tooltip = config.tooltip;
  _hintOverrides = config.hintOverrides;
  _elevation = config.elevation;
  _thickness = config.thickness;
  _flags = config._flags;
  _textDirection = config.textDirection;
  _sortKey = config.sortKey;
  _actions = Map<SemanticsAction, SemanticsActionHandler>.of(config._actions);
  _customSemanticsActions = Map<CustomSemanticsAction, VoidCallback>.of(config._customSemanticsActions);
  _actionsAsBits = config._actionsAsBits;
  _textSelection = config._textSelection;
  _isMultiline = config.isMultiline;
  _scrollPosition = config._scrollPosition;
  _scrollExtentMax = config._scrollExtentMax;
  _scrollExtentMin = config._scrollExtentMin;
  _mergeAllDescendantsIntoThisNode = config.isMergingSemanticsOfDescendants;
  _scrollChildCount = config.scrollChildCount;
  _scrollIndex = config.scrollIndex;
  indexInParent = config.indexInParent;
  _platformViewId = config._platformViewId;
  _maxValueLength = config._maxValueLength;
  _currentValueLength = config._currentValueLength;
  _replaceChildren(childrenInInversePaintOrder ?? const <SemanticsNode>[]);

  assert(
    !_canPerformAction(SemanticsAction.increase) || (value == '') == (increasedValue == ''),
    'A SemanticsNode with action "increase" needs to be annotated with either both "value" and "increasedValue" or neither',
  );
  assert(
    !_canPerformAction(SemanticsAction.decrease) || (value == '') == (decreasedValue == ''),
    'A SemanticsNode with action "increase" needs to be annotated with either both "value" and "decreasedValue" or neither',
  );
}