onCreateTap method

  1. @override
void onCreateTap(
  1. TapUpDetails details,
  2. EpochFromX epochFromX,
  3. QuoteFromY quoteFromY,
  4. EpochToX epochToX,
  5. QuoteToY quoteToY,
)
override

Handles tap events during the drawing creation process.

This method is called when the user taps on the chart while in the drawing addition state. It allows the drawing preview to:

  1. Capture coordinates needed to define the drawing's shape and position
  2. Update the underlying interactableDrawing with these coordinates
  3. Determine when the drawing creation is complete.

Different drawing tools require different numbers of taps to complete:

  • A horizontal line may require just one tap to define its position
  • A trend line requires two taps to define start and end points
  • A rectangle or triangle may require multiple taps to define vertices

When the drawing has received all necessary inputs, it should call the onDone callback to signal that creation is complete.

Parameters:

  • details: Information about the tap event
  • epochFromX: Function to convert X coordinate to epoch (timestamp)
  • quoteFromY: Function to convert Y coordinate to price/quote value
  • epochToX: Function to convert epoch (timestamp) to X coordinate
  • quoteToY: Function to convert price/quote value to Y coordinate
  • onDone: Callback to invoke when drawing creation is complete

Implementation

@override
void onCreateTap(
  TapUpDetails details,
  EpochFromX epochFromX,
  QuoteFromY quoteFromY,
  EpochToX epochToX,
  QuoteToY quoteToY,
) {
  final isFirstPoint = interactableDrawing.startPoint == null;

  createPoint(details, epochFromX, quoteFromY);

  if (isFirstPoint) {
    _animationController?.startAnimation();
  }
}