paint method

  1. @override
void paint(
  1. PaintingContext context,
  2. Offset offset
)
override

Paint this render object into the given context at the given offset.

Subclasses should override this method to provide a visual appearance for themselves. The render object's local coordinate system is axis-aligned with the coordinate system of the context's canvas and the render object's local origin (i.e, x=0 and y=0) is placed at the given offset in the context's canvas.

Do not call this function directly. If you wish to paint yourself, call markNeedsPaint instead to schedule a call to this function. If you wish to paint one of your children, call PaintingContext.paintChild on the given context.

When painting one of your children (via a paint child function on the given context), the current canvas held by the context might change because draw operations before and after painting children might need to be recorded on separate compositing layers.

Implementation

@override
void paint(PaintingContext context, Offset offset) {
  /// 折叠到展开  0-1
  /// 1, 围绕底部旋转 0-90     折叠状态 0           0,0.5
  /// 2,围绕顶部 90-0(-90>0),,围绕底部 0-90(要显示holder)  折叠状态 -90  -.5,.5
  /// 3,围绕顶部 90-0     折叠状态 90           -.5,0
  if (spinProgress == -.5) {
    ///折叠起来之后就不需要占位置了
    return;
  }
  var radians = spinProgress.abs() * pi;
  if (spinProgress > 0 && childCount == 2) {
    context.paintChild(firstChild!, offset);
  }
  if (spinProgress == .5) {
    return;
  }
  updateTransform(radians);
  context.pushTransform(
    needsCompositing,
    offset,
    _rotateTransform!,
    (context, offset) {
      context.paintChild(lastChild!, offset);
    },
  );
}