adjustOffset method

void adjustOffset({
  1. required double offsetX,
  2. required Curve curve,
  3. required bool trailing,
})

When nestedAction is open ,adjust currentOffset if nestedWidth > currentOffset

Implementation

void adjustOffset(
    {required double offsetX, required Curve curve, required bool trailing}) {
  controller.stop();
  final adjustOffsetAnimController = AnimationController(
      vsync: this, duration: const Duration(milliseconds: 150));
  final curveAnim =
      CurvedAnimation(parent: adjustOffsetAnimController, curve: curve);

  final endOffset = trailing ? -offsetX : offsetX;
  animation = Tween<double>(begin: currentOffset.dx, end: endOffset)
      .animate(curveAnim)
    ..addListener(() {
      if (lockAnim) return;
      this.currentOffset = Offset(animation.value, 0);
      setState(() {});
    });
  adjustOffsetAnimController.forward().whenCompleteOrCancel(() {
    adjustOffsetAnimController.dispose();
  });
}