applyParentData method

  1. @override
void applyParentData(
  1. RenderObject renderObject
)
override

Write the data from this widget into the given render object's parent data.

The framework calls this function whenever it detects that the RenderObject associated with the child has outdated RenderObject.parentData. For example, if the render object was recently inserted into the render tree, the render object's parent data might not match the data in this widget.

Subclasses are expected to override this function to copy data from their fields into the RenderObject.parentData field of the given render object. The render object's parent is guaranteed to have been created by a widget of type T, which usually means that this function can assume that the render object's parent data object inherits from a particular class.

If this function modifies data that can change the parent's layout or painting, this function is responsible for calling RenderObject.markNeedsLayout or RenderObject.markNeedsPaint on the parent, as appropriate.

Implementation

@override
void applyParentData(RenderObject renderObject) {
  final TableCellParentData parentData = renderObject.parentData! as TableCellParentData;
  if (parentData.verticalAlignment != verticalAlignment) {
    parentData.verticalAlignment = verticalAlignment;
    renderObject.parent?.markNeedsLayout();
  }
}