Unhandled Exception: NoSuchMethodError: The method '[]' was called on null.
when i am tapping or long tapping some times. getting this error and after that i am not able to get touch event.
i solved it by changing in one file named "PieChartPainter".
sectionsAngle was null and we are getting value of it by index.
to temporary solve it. i made following changes.
1) adding try catch.
2) checking section Angle is null or not and checking its length.
try {
for (int i = 0; i < data.sections.length; i++) {
final section = data.sections[i];
if(sectionsAngle!=null)
{
if(sectionsAngle.length > i ) {
double sectionAngle = sectionsAngle[i];
tempAngle %= 360;
sectionAngle %= 360;
/// degree criteria
final space = data.sectionsSpace / 2;
final fromDegree = tempAngle + space;
final toDegree = sectionAngle + tempAngle - space;
final isInDegree = touchAngle >= fromDegree &&
touchAngle <= toDegree;
/// radius criteria
final centerRadius = data.centerSpaceRadius;
final sectionRadius = centerRadius + section.radius;
final isInRadius = touchR > centerRadius && touchR <= sectionRadius;
if (isInDegree && isInRadius) {
foundSectionData = section;
foundSectionDataPosition = i;
break;
}
tempAngle += sectionAngle;
}
}
}
} on Exception catch(e)
{
print("caught");
}
catch(e)
{
print("caught");
}
I dont know my way is right or not as i ddnt go through whole library code. but i am not getting this error now. kindly guide.
Hi there,
I didn't understand the problem,
may I ask you to provide a reproducible code (include the main function)?
Thanks!
โโโโโโโโ Exception caught by gesture โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The following NoSuchMethodError was thrown while handling a gesture:
The method '[]' was called on null.
Receiver: null
Tried calling:
When the exception was thrown, this was the stack:
...
Handler: "onLongPressEnd"
Recognizer: LongPressGestureRecognizer#7f88e
debugOwner: GestureDetector
state: possible
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
i'm getting this error when long press the chart with given sample code.
Provide me a reproducer code.
It will be closed by tomorrow if you don't provide it.
Thanks!
I'm using your Example code for Pie chart.
File Name
https://github.com/imaNNeoFighT/fl_chart/blob/master/example/lib/pie_chart/samples/pie_chart_sample2.dart
https://github.com/imaNNeoFighT/fl_chart/blob/master/example/lib/pie_chart/samples/indicator.dart
Thank you, I found the problem.
It will be fixed in the next version,
stay tuned!
Waiting for the next version brother.
Thanks for waiting,
the next version will be 0.7.0
stay tuned!
Thanks!
Fixed in 0.7.0