createPoint method

void createPoint(
  1. TapUpDetails details,
  2. EpochFromX epochFromX,
  3. QuoteFromY quoteFromY
)
inherited

Handles the creation of trend line points during the drawing process.

This method manages the two-step process of creating a trend line:

  1. First click/tap creates the start point
  2. Second click/tap creates the end point and completes the line

The method automatically determines which point to create based on the current state of the trend line and calls the completion callback when both points are set.

Parameters:

  • position: Screen position where the user clicked/tapped
  • epochFromX: Function to convert screen X coordinate to epoch
  • quoteFromY: Function to convert screen Y coordinate to quote
  • onDone: Callback to execute when the trend line is complete

Implementation

void createPoint(
  TapUpDetails details,
  EpochFromX epochFromX,
  QuoteFromY quoteFromY,
) {
  if (interactableDrawing.startPoint == null) {
    interactableDrawing.startPoint = EdgePoint(
      epoch: epochFromX(details.localPosition.dx),
      quote: quoteFromY(details.localPosition.dy),
    );
    onAddingStateChange(AddingStateInfo(1, 2));
  } else {
    interactableDrawing.endPoint ??= EdgePoint(
      epoch: epochFromX(details.localPosition.dx),
      quote: quoteFromY(details.localPosition.dy),
    );
    onAddingStateChange(AddingStateInfo(2, 2));
  }
}