Repository navigation
Add null check for highlight on tap chart - #138
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I/flutter (30905): Handler: "onTapDown"
I/flutter (30905): Recognizer:
I/flutter (30905): TapGestureRecognizer#0c654
I/flutter (30905): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (30905): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter (30905): The following NoSuchMethodError was thrown while handling a gesture:
I/flutter (30905): The method 'getHighlight' was called on null.
I/flutter (30905): Receiver: null
I/flutter (30905): Tried calling: getHighlight(274.0, 97.58333333333331)
I/flutter (30905):
I/flutter (30905): When the exception was thrown, this was the stack:
I/flutter (30905): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
I/flutter (30905): #1 ChartPainter.getHighlightByTouchPoint (package:mp_chart/mp/painter/painter.dart:401:26)
I/flutter (30905): #2 BarLineChartBasePainter.getDataSetByTouchPoint (package:mp_chart/mp/painter/bar_line_chart_painter.dart:757:19)
I/flutter (30905): #3 BarLineScatterCandleBubbleState.onTapDown (package:mp_chart/mp/chart/bar_line_scatter_candle_bubble_chart.dart:59:56)
I/flutter (30905): #4 ChartState.build. (package:mp_chart/mp/chart/chart.dart:84:25)
I/flutter (30905): #5 OptimizedGestureDetector.build. (package:optimized_gesture_detector/optimized_gesture_detector.dart:131:27)
I/flutter (30905): #6 TapGestureRecognizer.handleTapDown. (package:flutter/src/gestures/tap.dart:502:60)
I/flutter (30905): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24)
I/flutter (30905): #8 TapGestureRecognizer.handleTapDown (package:flutter/src/gestures/tap.dart:502:11)
I/flutter (30905): #9 BaseTapGestureRecognizer._checkDown (package:flutter/src/gestures/tap.dart:276:5)
I/flutter (30905): #10 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:254:7)
I/flutter (30905): #11 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:158:27)
I/flutter (30905): #12 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:224:20)
I/flutter (30905): #13 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
I/flutter (30905): #14 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:158:7)
I/flutter (30905): #15 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:104:7)
I/flutter (30905): #16 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:88:7)
I/flutter (30905): #20 _invoke1 (dart:ui/hooks.dart:267:10)
I/flutter (30905): #21 _dispatchPointerDataPacket (dart:ui/hooks.dart:176:5)
I/flutter (30905): (elided 3 frames from dart:async)
If chart data is null or empty, above exception is happened.
getHighlight is of IHighlighter and highlighter is set by initDefaultWithData.
https://github.com/SunPointed/MPFlutterChart/blob/master/mp_chart/lib/mp/painter/bar_line_chart_painter.dart#L246
initDefaultWithData is not called if chart data is null or empty.
https://github.com/SunPointed/MPFlutterChart/blob/master/mp_chart/lib/mp/painter/painter.dart#L168
My change is add to null check for getHighlightByTouchPoint.
Please check it. Thank you very much.