TrendLineAddingPreviewMobile class
Mobile-specific implementation for trend line adding preview.
This class handles trend line creation and preview specifically for mobile/touch
environments where users interact via touch gestures. It extends
TrendLineAddingPreview to inherit shared functionality while implementing
mobile-specific interaction patterns optimized for touch interfaces.
This mobile preview provides immediate focus mode by:
- Automatically placing the trend line in the center of the chart
- Immediately completing the adding process for instant focus mode
- Delegating visual rendering to the main drawing for consistency
- Providing full functionality (drag points, neon effects, proper labeling)
Mobile Interaction Flow:
- Auto-Initialization: Automatically creates centered start and end points
- Immediate Focus: Instantly transitions to selected state with full functionality
- Drag Interaction: Users can drag individual points or the entire line
- Full Visual Feedback: Shows neon effects, focused circles, and alignment guides
Key Features:
- Immediate Focus Mode: No preview phase, instant selected state
- Touch-Optimized: Full drag functionality for repositioning points and lines
- Visual Consistency: Identical appearance to the main drawing
- Centered Positioning: Intelligent default placement in chart center
Default Positioning:
When initialized, the trend line is automatically positioned with:
- Start point at bottom-left area (20% from left, 80% from top)
- End point at upper-right area (70% from left, 25% from top)
- This provides a diagonal trend line spanning nicely across the chart
Usage:
This class is typically instantiated by the drawing system when a user selects the trend line tool on a mobile platform:
final preview = TrendLineAddingPreviewMobile(
interactiveLayerBehaviour: mobileBehaviour,
interactableDrawing: trendLineDrawing,
);
- Inheritance
-
- Object
- DrawingAddingPreview<
TrendLineInteractableDrawing> - TrendLineAddingPreviewMobile
Constructors
- TrendLineAddingPreviewMobile({required InteractiveLayerBehaviour interactiveLayerBehaviour, required TrendLineInteractableDrawing interactableDrawing, required dynamic onAddingStateChange(AddingStateInfo)})
- Initializes TrendLineInteractableDrawing.
Properties
- canStartDragFromEmpty → bool
-
Whether this preview can start a drag gesture even when nothing has
been placed yet, i.e. before hitTest has anything to return
truefor.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
The id of the drawing which should be unique for each drawing in
InteractiveLayer.no setteroverride - interactableDrawing → TrendLineInteractableDrawing
-
The reference to the InteractableDrawing instance of the drawing tool
that is going to be added.
finalinherited
- interactiveLayerBehaviour → InteractiveLayerBehaviour
-
The current interactive layer behaviour which is active and defines how
this preview should behave.
finalinherited
- onAddingStateChange → dynamic Function(AddingStateInfo)
-
A callback to the current step of the tool adding process.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createPoint(
TapUpDetails details, EpochFromX epochFromX, QuoteFromY quoteFromY) → void -
Handles the creation of trend line points during the drawing process.
inherited
-
drawPointGuidesAndLabels(
Canvas canvas, Size size, Offset pointOffset, EpochToX epochToX, QuoteToY quoteToY, EpochFromX epochFromX, QuoteFromY quoteFromY, ChartConfig chartConfig, ChartTheme chartTheme, {bool showGuides = true, bool showLabels = true}) → void -
Draws alignment guides and labels for a point during interactions.
inherited
-
drawPreviewLine(
Canvas canvas, Offset startPosition, Offset endPosition, DrawingPaintStyle paintStyle, LineStyle lineStyle, {bool isDashed = false}) → void -
Draws a preview line between two points with optional dashed styling.
inherited
-
drawStyledFocusedCircle(
DrawingPaintStyle paintStyle, LineStyle lineStyle, Canvas canvas, Offset offset, double animationPercent) → void -
Draws a focused circle effect around a point during interactions.
inherited
-
drawStyledPoint(
EdgePoint point, EpochToX epochToX, QuoteToY quoteToY, Canvas canvas, DrawingPaintStyle paintStyle, LineStyle lineStyle, {double radius = pointRadius}) → void -
Draws a trend line point with consistent styling across platforms.
inherited
-
drawStyledPointOffset(
Offset offset, EpochToX epochToX, QuoteToY quoteToY, Canvas canvas, DrawingPaintStyle paintStyle, LineStyle lineStyle, {double radius = pointRadius}) → void -
Draws a trend line point at a specific screen offset with consistent styling.
inherited
-
edgePointToOffset(
EdgePoint point, EpochToX epochToX, QuoteToY quoteToY) → Offset -
Converts a chart coordinate point to screen coordinates.
inherited
-
getStyles(
) → (DrawingPaintStyle, LineStyle) -
Retrieves the current drawing paint style and line style configuration.
inherited
-
hitTest(
Offset offset, EpochToX epochToX, QuoteToY quoteToY) → bool -
Returns
trueif the drawing tool is hit by the given offset.override -
isInViewPort(
EpochRange epochRange, QuoteRange quoteRange) → bool -
Determines if the drawing preview is within the current chart viewport.
inherited
-
isValidPoint(
EdgePoint? point) → bool -
Validates whether a point is valid and can be used for drawing.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
offsetToEdgePoint(
Offset offset, EpochFromX epochFromX, QuoteFromY quoteFromY) → EdgePoint -
Converts screen coordinates to a chart coordinate point.
inherited
-
onCreateTap(
TapUpDetails details, EpochFromX epochFromX, QuoteFromY quoteFromY, EpochToX epochToX, QuoteToY quoteToY) → void -
Handles tap events during the drawing creation process.
override
-
onDragEnd(
DragEndDetails details, EpochFromX epochFromX, QuoteFromY quoteFromY, EpochToX epochToX, QuoteToY quoteToY) → void -
Handles the end of a drag gesture during drawing creation.
override
-
onDragStart(
DragStartDetails details, EpochFromX epochFromX, QuoteFromY quoteFromY, EpochToX epochToX, QuoteToY quoteToY) → void -
Handles the start of a drag gesture during drawing creation.
override
-
onDragUpdate(
DragUpdateDetails details, EpochFromX epochFromX, QuoteFromY quoteFromY, EpochToX epochToX, QuoteToY quoteToY) → void -
Handles updates during a drag gesture for drawing creation.
override
-
onHover(
PointerHoverEvent event, EpochFromX epochFromX, QuoteFromY quoteFromY, EpochToX epochToX, QuoteToY quoteToY) → void -
Handles hover events during drawing creation (desktop platforms).
inherited
-
onLongPressEnd(
EpochFromX epochFromX, QuoteFromY quoteFromY, EpochToX epochToX, QuoteToY quoteToY) → void -
Called when a long press ends on the drawing tool.
inherited
-
onLongPressStart(
Offset localPosition, EpochFromX epochFromX, QuoteFromY quoteFromY, EpochToX epochToX, QuoteToY quoteToY) → void -
Called when a long press starts on the drawing tool.
inherited
-
paint(
Canvas canvas, Size size, EpochToX epochToX, QuoteToY quoteToY, AnimationInfo animationInfo, ChartConfig chartConfig, ChartTheme chartTheme, GetDrawingState getDrawingState) → void -
Paints the drawing tool on the chart.
override
-
paintOverYAxis(
Canvas canvas, Size size, EpochToX epochToX, QuoteToY quoteToY, EpochFromX? epochFromX, QuoteFromY? quoteFromY, AnimationInfo animationInfo, ChartConfig chartConfig, ChartTheme chartTheme, GetDrawingState getDrawingState) → void -
Paints the drawing tool chart but over the Y-axis.
override
-
shouldRepaint(
Set< DrawingToolState> drawingState, DrawingV2 oldDrawing) → bool -
Determines if the drawing preview needs to be repainted.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited