@@ -485,7 +485,7 @@ class RenderChartArea extends RenderBox
485485 }
486486
487487 bool _isCartesianAxesHit (Offset globalPosition) {
488- if (_cartesianAxes != null ) {
488+ if (_cartesianAxes != null && attached ) {
489489 return true ;
490490 }
491491 return false ;
@@ -500,21 +500,27 @@ class RenderChartArea extends RenderBox
500500 }
501501
502502 bool _isBehaviorAreaHit (Offset globalPosition) {
503- if (_behaviorArea != null ) {
503+ if (_behaviorArea != null && attached ) {
504504 return true ;
505505 }
506506 return false ;
507507 }
508508
509509 @protected
510510 void _handlePointerEnter (PointerEnterEvent details) {
511+ if (! attached) {
512+ return ;
513+ }
511514 if (_isBehaviorAreaHit (details.position)) {
512515 _behaviorArea! .handlePointerEnter (details);
513516 }
514517 }
515518
516519 @protected
517520 void _handlePointerDown (PointerDownEvent details) {
521+ if (! attached) {
522+ return ;
523+ }
518524 onChartTouchInteractionDown? .call (ChartTouchInteractionArgs ()
519525 ..position = globalToLocal (details.position));
520526 if (_isPlotAreaHit (details.position)) {
@@ -528,12 +534,18 @@ class RenderChartArea extends RenderBox
528534
529535 @protected
530536 void _handlePointerMove (PointerMoveEvent details) {
537+ if (! attached) {
538+ return ;
539+ }
531540 onChartTouchInteractionMove? .call (ChartTouchInteractionArgs ()
532541 ..position = globalToLocal (details.position));
533542 }
534543
535544 @protected
536545 void _handlePointerHover (PointerHoverEvent details) {
546+ if (! attached) {
547+ return ;
548+ }
537549 if (_isCartesianAxesHit (details.position)) {
538550 _cartesianAxes? .visitChildren ((RenderObject child) {
539551 if (child is RenderChartAxis ) {
@@ -557,6 +569,9 @@ class RenderChartArea extends RenderBox
557569
558570 @protected
559571 void _handlePointerUp (PointerUpEvent details) {
572+ if (! attached) {
573+ return ;
574+ }
560575 onChartTouchInteractionUp? .call (ChartTouchInteractionArgs ()
561576 ..position = globalToLocal (details.position));
562577 if (_isPlotAreaHit (details.position)) {
@@ -570,13 +585,19 @@ class RenderChartArea extends RenderBox
570585
571586 @protected
572587 void _handlePointerExit (PointerExitEvent details) {
588+ if (! attached) {
589+ return ;
590+ }
573591 if (_isBehaviorAreaHit (details.position)) {
574592 _behaviorArea? .handlePointerExit (details);
575593 }
576594 }
577595
578596 @protected
579597 void _handleLongPressStart (LongPressStartDetails details) {
598+ if (! attached) {
599+ return ;
600+ }
580601 if (_isPlotAreaHit (details.globalPosition)) {
581602 _plotArea! .isTooltipActivated = false ;
582603 RenderBox ? child = _plotArea? .lastChild;
@@ -596,27 +617,39 @@ class RenderChartArea extends RenderBox
596617
597618 @protected
598619 void _handleLongPressMoveUpdate (LongPressMoveUpdateDetails details) {
620+ if (! attached) {
621+ return ;
622+ }
599623 if (_isBehaviorAreaHit (details.globalPosition)) {
600624 _behaviorArea? .handleLongPressMoveUpdate (details);
601625 }
602626 }
603627
604628 @protected
605629 void _handleLongPressEnd (LongPressEndDetails details) {
630+ if (! attached) {
631+ return ;
632+ }
606633 if (_isBehaviorAreaHit (details.globalPosition)) {
607634 _behaviorArea? .handleLongPressEnd (details);
608635 }
609636 }
610637
611638 @protected
612639 void _handleTapDown (TapDownDetails details) {
640+ if (! attached) {
641+ return ;
642+ }
613643 if (_isBehaviorAreaHit (details.globalPosition)) {
614644 _behaviorArea? .handleTapDown (details);
615645 }
616646 }
617647
618648 @protected
619649 void _handleTapUp (TapUpDetails details) {
650+ if (! attached) {
651+ return ;
652+ }
620653 if (_isCartesianAxesHit (details.globalPosition)) {
621654 _cartesianAxes? .visitChildren ((RenderObject child) {
622655 if (child is RenderChartAxis ) {
@@ -642,12 +675,15 @@ class RenderChartArea extends RenderBox
642675 }
643676
644677 void _handleDoubleTapDown (TapDownDetails details) {
678+ if (! attached) {
679+ return ;
680+ }
645681 _doubleTapPosition = details.globalPosition;
646682 }
647683
648684 @protected
649685 void _handleDoubleTap () {
650- if (_doubleTapPosition == null ) {
686+ if (_doubleTapPosition == null || ! attached ) {
651687 return ;
652688 }
653689 if (_isPlotAreaHit (_doubleTapPosition! )) {
@@ -669,11 +705,17 @@ class RenderChartArea extends RenderBox
669705 }
670706
671707 void _handleDoubleTapCancel () {
708+ if (! attached) {
709+ return ;
710+ }
672711 _doubleTapPosition = null ;
673712 }
674713
675714 @protected
676715 void _handleScaleStart (ScaleStartDetails details) {
716+ if (! attached) {
717+ return ;
718+ }
677719 if (_isBehaviorAreaHit (details.focalPoint)) {
678720 _isScaled = true ;
679721 _behaviorArea? .handleScaleStart (details);
@@ -682,6 +724,9 @@ class RenderChartArea extends RenderBox
682724
683725 @protected
684726 void _handleScaleUpdate (ScaleUpdateDetails details) {
727+ if (! attached) {
728+ return ;
729+ }
685730 if (_isPlotAreaHit (details.focalPoint)) {
686731 _plotArea? .visitChildren ((RenderObject child) {
687732 if (child is ChartSeriesRenderer ) {
@@ -697,6 +742,9 @@ class RenderChartArea extends RenderBox
697742
698743 @protected
699744 void _handleScaleEnd (ScaleEndDetails details) {
745+ if (! attached) {
746+ return ;
747+ }
700748 if (_isScaled) {
701749 _isScaled = false ;
702750 _behaviorArea? .handleScaleEnd (details);
@@ -705,6 +753,9 @@ class RenderChartArea extends RenderBox
705753
706754 @protected
707755 void _handleHorizontalDragStart (DragStartDetails details) {
756+ if (! attached) {
757+ return ;
758+ }
708759 if (_isBehaviorAreaHit (details.globalPosition)) {
709760 _isPanned = true ;
710761 _behaviorArea! .handleHorizontalDragStart (details);
@@ -713,6 +764,9 @@ class RenderChartArea extends RenderBox
713764
714765 @protected
715766 void _handleHorizontalDragUpdate (DragUpdateDetails details) {
767+ if (! attached) {
768+ return ;
769+ }
716770 if (_isBehaviorAreaHit (details.globalPosition)) {
717771 _isPanned = true ;
718772 _behaviorArea! .handleHorizontalDragUpdate (details);
@@ -721,6 +775,9 @@ class RenderChartArea extends RenderBox
721775
722776 @protected
723777 void _handleHorizontalDragEnd (DragEndDetails details) {
778+ if (! attached) {
779+ return ;
780+ }
724781 if (_isPanned) {
725782 _isPanned = false ;
726783 _behaviorArea! .handleHorizontalDragEnd (details);
@@ -729,6 +786,9 @@ class RenderChartArea extends RenderBox
729786
730787 @protected
731788 void _handleVerticalDragStart (DragStartDetails details) {
789+ if (! attached) {
790+ return ;
791+ }
732792 if (_isBehaviorAreaHit (details.globalPosition)) {
733793 _isPanned = true ;
734794 _behaviorArea! .handleVerticalDragStart (details);
@@ -737,6 +797,9 @@ class RenderChartArea extends RenderBox
737797
738798 @protected
739799 void _handleVerticalDragUpdate (DragUpdateDetails details) {
800+ if (! attached) {
801+ return ;
802+ }
740803 if (_isBehaviorAreaHit (details.globalPosition)) {
741804 _isPanned = true ;
742805 _behaviorArea! .handleVerticalDragUpdate (details);
@@ -745,6 +808,9 @@ class RenderChartArea extends RenderBox
745808
746809 @protected
747810 void _handleVerticalDragEnd (DragEndDetails details) {
811+ if (! attached) {
812+ return ;
813+ }
748814 if (_isPanned) {
749815 _isPanned = false ;
750816 _behaviorArea! .handleVerticalDragEnd (details);
@@ -3226,10 +3292,16 @@ class RenderLoadingIndicator extends RenderProxyBox
32263292 }
32273293
32283294 void handleScaleStart (ScaleStartDetails details) {
3295+ if (! attached) {
3296+ return ;
3297+ }
32293298 _startPosition = globalToLocal (details.focalPoint);
32303299 }
32313300
32323301 void handleScaleUpdate (ScaleUpdateDetails details) {
3302+ if (! attached) {
3303+ return ;
3304+ }
32333305 _endPosition = globalToLocal (details.focalPoint);
32343306 }
32353307
@@ -3238,10 +3310,16 @@ class RenderLoadingIndicator extends RenderProxyBox
32383310 }
32393311
32403312 void handleDragStart (DragStartDetails details) {
3313+ if (! attached) {
3314+ return ;
3315+ }
32413316 _startPosition = globalToLocal (details.globalPosition);
32423317 }
32433318
32443319 void handleDragUpdate (DragUpdateDetails details) {
3320+ if (! attached) {
3321+ return ;
3322+ }
32453323 _endPosition = globalToLocal (details.globalPosition);
32463324 }
32473325
0 commit comments