diff --git a/lib/src/deriv_chart/chart/main_chart.dart b/lib/src/deriv_chart/chart/main_chart.dart index 54c050867..e729aef57 100644 --- a/lib/src/deriv_chart/chart/main_chart.dart +++ b/lib/src/deriv_chart/chart/main_chart.dart @@ -399,6 +399,11 @@ class _ChartImplementationState extends BasicChartState { @override Widget build(BuildContext context) => LayoutBuilder( + // Force remount when markerSeries changes. + // LayoutBuilder only re-invokes its builder on constraint changes; + // without a key that tracks markerSeries identity, the old + // MarkerArea subtree persists after trade-type switches. + key: ObjectKey(widget.markerSeries), builder: (BuildContext context, BoxConstraints constraints) { final XAxisModel xAxis = context.watch(); @@ -579,17 +584,20 @@ class _ChartImplementationState extends BasicChartState { ), ); - Widget _buildMarkerArea() => MultipleAnimatedBuilder( - animations: [ - currentTickAnimation, - topBoundQuoteAnimationController, - bottomBoundQuoteAnimationController - ], - builder: (BuildContext context, _) => MarkerArea( - markerSeries: widget.markerSeries!, - quoteToCanvasY: chartQuoteToCanvasY, - animationInfo: AnimationInfo( - currentTickPercent: currentTickAnimation.value, + Widget _buildMarkerArea() => KeyedSubtree( + key: ObjectKey(widget.markerSeries), + child: MultipleAnimatedBuilder( + animations: [ + currentTickAnimation, + topBoundQuoteAnimationController, + bottomBoundQuoteAnimationController + ], + builder: (BuildContext context, _) => MarkerArea( + markerSeries: widget.markerSeries!, + quoteToCanvasY: chartQuoteToCanvasY, + animationInfo: AnimationInfo( + currentTickPercent: currentTickAnimation.value, + ), ), ), );