paint method

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

READ AGAIN HERE, and not only at layout: the mark moves when the content above it changes height, and that leaves this box's own constraints exactly as they were -- so RenderObject.layout returns without running, and a shift written only at layout would be the one from the width before. By paint the whole stack is placed.

Implementation

@override
void paint(PaintingContext context, Offset offset) {
  final child = this.child;
  if (child != null) (child.parentData! as BoxParentData).offset = _spotAt(_fill ? _laidArea ?? Size.zero : _own);
  // AN AREA THAT CAME OUT ANOTHER SIZE with the stack's own size as it
  // was leaves this box's constraints alone, and its layout with them:
  // laid out again after the frame, where nothing is being laid out or
  // painted that the change could upset.
  if (_fill && child != null) {
    final area = _area;
    if (area != null && area != _laidArea) {
      SchedulerBinding.instance.addPostFrameCallback((_) {
        if (attached) markNeedsLayout();
      });
    }
  }
  super.paint(context, offset);
}