attach method

  1. @override
Widget? attach(
  1. BuildContext context,
  2. ViewController controller
)
override

Implementation

@override
Widget? attach(
  BuildContext context,
  ViewController controller,
) {
  return LayoutBuilder(
    builder: (context, constraints) {
      bool isPositiveX = x > 0;
      bool isPositiveY = y > 0;
      double mX = constraints.maxWidth * (x / 50);
      double mY = constraints.maxHeight * (y / 50);
      return Padding(
        padding: EdgeInsets.only(
          left: isPositiveX ? mX : 0,
          right: !isPositiveX ? mX * -1 : 0,
          top: !isPositiveY ? mY * -1 : 0,
          bottom: isPositiveY ? mY : 0,
        ),
        child: controller.child,
      );
    },
  );
}