createPoint method
Handles the creation of trend line points during the drawing process.
This method manages the two-step process of creating a trend line:
- First click/tap creates the start point
- 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/tappedepochFromX: Function to convert screen X coordinate to epochquoteFromY: Function to convert screen Y coordinate to quoteonDone: 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));
}
}