paintChild method

  1. @override
void paintChild (int i, { Matrix4 transform, double opacity: 1.0 })
override

Paint the ith child using the given transform.

The child will be painted in a coordinate system that concatenates the container's coordinate system with the given transform. The origin of the parent's coordinate system is the upper left corner of the parent, with x increasing rightward and y increasing downward.

The container will clip the children to its bounds.

Implementation

@override
void paintChild(int i, { Matrix4 transform, double opacity = 1.0 }) {
  transform ??= Matrix4.identity();
  final RenderBox child = _randomAccessChildren[i];
  final FlowParentData childParentData = child.parentData;
  assert(() {
    if (childParentData._transform != null) {
      throw FlutterError(
        'Cannot call paintChild twice for the same child.\n'
        'The flow delegate of type ${_delegate.runtimeType} attempted to '
        'paint child $i multiple times, which is not permitted.'
      );
    }
    return true;
  }());
  _lastPaintOrder.add(i);
  childParentData._transform = transform;

  // We return after assigning _transform so that the transparent child can
  // still be hit tested at the correct location.
  if (opacity == 0.0)
    return;

  void painter(PaintingContext context, Offset offset) {
    context.paintChild(child, offset);
  }
  if (opacity == 1.0) {
    _paintingContext.pushTransform(needsCompositing, _paintingOffset, transform, painter);
  } else {
    _paintingContext.pushOpacity(_paintingOffset, _getAlphaFromOpacity(opacity), (PaintingContext context, Offset offset) {
      context.pushTransform(needsCompositing, offset, transform, painter);
    });
  }
}