buildPositioned method

Widget buildPositioned({
  1. required double offset,
  2. required double hitAreaSize,
  3. required Widget child,
})

Builds a positioned widget for this handle.

offset is the distance from the boundary to center the handle on. hitAreaSize is the total size of the hit area (handle + snap padding). child is the handle content widget.

Implementation

Widget buildPositioned({
  required double offset,
  required double hitAreaSize,
  required Widget child,
}) {
  // Corner handles have fixed size at corner positions
  // Edge handles stretch along the edge and center their content
  return switch (this) {
    ResizeHandle.topLeft => Positioned(
      left: -offset,
      top: -offset,
      width: hitAreaSize,
      height: hitAreaSize,
      child: child,
    ),
    ResizeHandle.topRight => Positioned(
      right: -offset,
      top: -offset,
      width: hitAreaSize,
      height: hitAreaSize,
      child: child,
    ),
    ResizeHandle.bottomLeft => Positioned(
      left: -offset,
      bottom: -offset,
      width: hitAreaSize,
      height: hitAreaSize,
      child: child,
    ),
    ResizeHandle.bottomRight => Positioned(
      right: -offset,
      bottom: -offset,
      width: hitAreaSize,
      height: hitAreaSize,
      child: child,
    ),
    ResizeHandle.topCenter => Positioned(
      left: 0,
      right: 0,
      top: -offset,
      child: Center(
        child: SizedBox(
          width: hitAreaSize,
          height: hitAreaSize,
          child: child,
        ),
      ),
    ),
    ResizeHandle.bottomCenter => Positioned(
      left: 0,
      right: 0,
      bottom: -offset,
      child: Center(
        child: SizedBox(
          width: hitAreaSize,
          height: hitAreaSize,
          child: child,
        ),
      ),
    ),
    ResizeHandle.centerLeft => Positioned(
      top: 0,
      bottom: 0,
      left: -offset,
      child: Center(
        child: SizedBox(
          width: hitAreaSize,
          height: hitAreaSize,
          child: child,
        ),
      ),
    ),
    ResizeHandle.centerRight => Positioned(
      top: 0,
      bottom: 0,
      right: -offset,
      child: Center(
        child: SizedBox(
          width: hitAreaSize,
          height: hitAreaSize,
          child: child,
        ),
      ),
    ),
  };
}