offset method

void offset({
  1. required Offset offset,
  2. required VoidCallback paint,
  3. Rect? bounds,
  4. LayerKey<Layer>? key,
})

Pushes an OffsetLayer to the compositing tree, calling paint to paint on top of the layer.

The bounds argument defines the bounds in which the paint should paint, this is useful for debugging tools and does not affect rendering.

See also:

Implementation

void offset({
  required Offset offset,
  required VoidCallback paint,
  Rect? bounds,
  LayerKey? key,
}) {
  OffsetLayer layer;
  if (key?.layer is OffsetLayer) {
    layer = (key!.layer! as OffsetLayer)..offset = offset;
  } else {
    layer = OffsetLayer(offset: offset);
    key?.layer = layer;
  }
  push(layer: layer, paint: paint, bounds: bounds);
}