updateNode method Null safety

void updateNode(
  1. {required int id,
  2. required int flags,
  3. required int actions,
  4. required int maxValueLength,
  5. required int currentValueLength,
  6. required int textSelectionBase,
  7. required int textSelectionExtent,
  8. required int platformViewId,
  9. required int scrollChildren,
  10. required int scrollIndex,
  11. required double scrollPosition,
  12. required double scrollExtentMax,
  13. required double scrollExtentMin,
  14. required double elevation,
  15. required double thickness,
  16. required Rect rect,
  17. required String label,
  18. required List<StringAttribute> labelAttributes,
  19. required String value,
  20. required List<StringAttribute> valueAttributes,
  21. required String increasedValue,
  22. required List<StringAttribute> increasedValueAttributes,
  23. required String decreasedValue,
  24. required List<StringAttribute> decreasedValueAttributes,
  25. required String hint,
  26. required List<StringAttribute> hintAttributes,
  27. String? tooltip,
  28. TextDirection? textDirection,
  29. required Float64List transform,
  30. required Int32List childrenInTraversalOrder,
  31. required Int32List childrenInHitTestOrder,
  32. required Int32List additionalActions}
)

Update the information associated with the node with the given id.

The semantics nodes form a tree, with the root of the tree always having an id of zero. The childrenInTraversalOrder and childrenInHitTestOrder are the ids of the nodes that are immediate children of this node. The former enumerates children in traversal order, and the latter enumerates the same children in the hit test order. The two lists must have the same length and contain the same ids. They may only differ in the order the ids are listed in. For more information about different child orders, see DebugSemanticsDumpOrder.

The system retains the nodes that are currently reachable from the root. A given update need not contain information for nodes that do not change in the update. If a node is not reachable from the root after an update, the node will be discarded from the tree.

The flags are a bit field of SemanticsFlags that apply to this node.

The actions are a bit field of SemanticsActions that can be undertaken by this node. If the user wishes to undertake one of these actions on this node, the PlatformDispatcher.onSemanticsAction will be called with id and one of the possible SemanticsActions. Because the semantics tree is maintained asynchronously, the PlatformDispatcher.onSemanticsAction callback might be called with an action that is no longer possible.

The label is a string that describes this node. The value property describes the current value of the node as a string. The increasedValue string will become the value string after a SemanticsAction.increase action is performed. The decreasedValue string will become the value string after a SemanticsAction.decrease action is performed. The hint string describes what result an action performed on this node has. The reading direction of all these strings is given by textDirection.

The labelAttirbutes, valueAttirbutes, hintAttributes, increasedValueAttirbutes, and decreasedValueAttributes are the lists of StringAttribute carried by the label, value, hint, increasedValue, and decreasedValue respectively. Their contents must not be changed during the semantics update.

The tooltip is a string that describe additional information when user hover or long press on the backing widget of this semantics node.

The fields textSelectionBase and textSelectionExtent describe the currently selected text within value. A value of -1 indicates no current text selection base or extent.

The field maxValueLength is used to indicate that an editable text field has a limit on the number of characters entered. If it is -1 there is no limit on the number of characters entered. The field currentValueLength indicates how much of that limit has already been used up. When maxValueLength is >= 0, currentValueLength must also be

= 0, otherwise it should be specified to be -1.

The field platformViewId references the platform view, whose semantics nodes will be added as children to this node. If a platform view is specified, childrenInHitTestOrder and childrenInTraversalOrder must be empty. A value of -1 indicates that this node is not associated with a platform view.

For scrollable nodes scrollPosition describes the current scroll position in logical pixel. scrollExtentMax and scrollExtentMin describe the maximum and minimum in-rage values that scrollPosition can be. Both or either may be infinity to indicate unbound scrolling. The value for scrollPosition can (temporarily) be outside this range, for example during an overscroll. scrollChildren is the count of the total number of child nodes that contribute semantics and scrollIndex is the index of the first visible child node that contributes semantics.

The rect is the region occupied by this node in its own coordinate system.

The transform is a matrix that maps this node's coordinate system into its parent's coordinate system.

The elevation describes the distance in z-direction between this node and the elevation of the parent.

The thickness describes how much space this node occupies in the z-direction starting at elevation. Basically, in the z-direction the node starts at elevation above the parent and ends at elevation + thickness above the parent.

Implementation

void updateNode({
  required int id,
  required int flags,
  required int actions,
  required int maxValueLength,
  required int currentValueLength,
  required int textSelectionBase,
  required int textSelectionExtent,
  required int platformViewId,
  required int scrollChildren,
  required int scrollIndex,
  required double scrollPosition,
  required double scrollExtentMax,
  required double scrollExtentMin,
  required double elevation,
  required double thickness,
  required Rect rect,
  required String label,
  required List<StringAttribute> labelAttributes,
  required String value,
  required List<StringAttribute> valueAttributes,
  required String increasedValue,
  required List<StringAttribute> increasedValueAttributes,
  required String decreasedValue,
  required List<StringAttribute> decreasedValueAttributes,
  required String hint,
  required List<StringAttribute> hintAttributes,
  String? tooltip,
  TextDirection? textDirection,
  required Float64List transform,
  required Int32List childrenInTraversalOrder,
  required Int32List childrenInHitTestOrder,
  required Int32List additionalActions,
}) {
  assert(_matrix4IsValid(transform));
  assert(
    scrollChildren == 0 || scrollChildren == null || (scrollChildren > 0 && childrenInHitTestOrder != null),
    'If a node has scrollChildren, it must have childrenInHitTestOrder',
  );
  _updateNode(
    id,
    flags,
    actions,
    maxValueLength,
    currentValueLength,
    textSelectionBase,
    textSelectionExtent,
    platformViewId,
    scrollChildren,
    scrollIndex,
    scrollPosition,
    scrollExtentMax,
    scrollExtentMin,
    rect.left,
    rect.top,
    rect.right,
    rect.bottom,
    elevation,
    thickness,
    label,
    labelAttributes,
    value,
    valueAttributes,
    increasedValue,
    increasedValueAttributes,
    decreasedValue,
    decreasedValueAttributes,
    hint,
    hintAttributes,
    tooltip ?? '',
    textDirection != null ? textDirection.index + 1 : 0,
    transform,
    childrenInTraversalOrder,
    childrenInHitTestOrder,
    additionalActions,
  );
}