findSide method

void findSide()

The findSide method is a helper function used to determine which side of the Flipper is logically to be displayed. It uses the current dragHorizontal and dragVertical values, as well as the dragAxis property to determine whether the front or back side of the Flipper is to be displayed.

The method updates the following properties:

isFront : A boolean property indicating whether the front side of the DragFlipper is currently being displayed. isInverted : A boolean property indicating whether the flipper is currently being displayed in an inverted or a normal view.

The findSide method is called inside the animationController.addListener method in the initState function and onPanUpdate function, thus it will be called every time the flipper is dragged manually or by animationController.

This function is important for the correct functioning of the DragFlipper widget and should not be modified or removed unless absolutely necessary.

Implementation

void findSide() {
  if (widget.controller.dragAxis == DragAxis.horizontal) {
    if (dragHorizontal <= 90 || dragHorizontal >= 270) {
      isFront = true;
    } else {
      isFront = false;
    }
  } else if (widget.controller.dragAxis == DragAxis.vertical) {
    if (dragVertical <= 90 || dragVertical >= 270) {
      isFront = true;
      isInverted = false;
    } else {
      isFront = false;
      isInverted = true;
    }
  } else {
    if ((dragVertical <= 90 || dragVertical >= 270) &&
        (dragHorizontal <= 90 || dragHorizontal >= 270)) {
      isFront = true;
      isInverted = false;
    } else if ((dragVertical > 90 && dragVertical < 270) &&
        (dragHorizontal > 90 && dragHorizontal < 270)) {
      isFront = true;
      isInverted = true;
    } else if ((dragVertical > 90 && dragVertical < 270) &&
        (dragHorizontal <= 90 || dragHorizontal >= 270)) {
      isFront = false;
      isInverted = true;
    } else if ((dragVertical <= 90 || dragVertical >= 270) &&
        (dragHorizontal > 90 && dragHorizontal < 270)) {
      isFront = false;
      isInverted = false;
    }
  }
}