syncfusion / flutter-examples

This repository contains the Syncfusion Flutter UI widgets examples and the guide to use them.
Other
1.98k stars 775 forks source link

LateInitializationError: Field 'labelRect' has not been initialized. #809

Closed woyl closed 8 months ago

woyl commented 1 year ago

When the exception was thrown, this was the stack:

0 ChartPoint.labelRect (package:syncfusion_flutter_charts/src/circular_chart/renderer/chart_point.dart)

1 renderCircularDataLabel (package:syncfusion_flutter_charts/src/circular_chart/renderer/data_label_renderer.dart:585:33)

2 _CircularDataLabelPainter.paint (package:syncfusion_flutter_charts/src/circular_chart/renderer/data_label_renderer.dart:144:9)

3 RenderCustomPaint._paintWithPainter (package:flutter/src/rendering/custom_paint.dart:573:13)

4 RenderCustomPaint.paint (package:flutter/src/rendering/custom_paint.dart:615:7)

5 RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:3059:7)

6 PaintingContext.paintChild (package:flutter/src/rendering/object.dart:253:13)

7 RenderProxyBoxMixin.paint (package:flutter/src/rendering/proxy_box.dart:146:15)

8 RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:3059:7)

9 PaintingContext._repaintCompositedChild (package:flutter/src/rendering/object.dart:169:11)

10 PaintingContext.repaintCompositedChild (package:flutter/src/rendering/object.dart:112:5)

11 PipelineOwner.flushPaint (package:flutter/src/rendering/object.dart:1147:31)

12 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:494:19)

13 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:905:13)

14 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:358:5)

15 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1284:15)

16 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1214:9)

17 SchedulerBinding.scheduleWarmUpFrame. (package:flutter/src/scheduler/binding.dart:939:7)

21 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)

(elided 3 frames from class _Timer and dart:async-patch) The following RenderObject was being processed when the exception was fired: RenderCustomPaint#ec66f relayoutBoundary=up2 ... parentData: (can use size) ... constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=314.0) ... size: Size(0.0, 0.0) ... painter: _CircularDataLabelPainter#b7958(ValueNotifier#8e95c(42)) RenderObject: RenderCustomPaint#ec66f relayoutBoundary=up2 parentData: (can use size) constraints: BoxConstraints(0.0<=w<=392.7, 0.0<=h<=314.0) size: Size(0.0, 0.0) painter: _CircularDataLabelPainter#b7958(ValueNotifier#8e95c(42))

sfHariHaraSudhan commented 1 year ago

Hi @woyl

Unfortunately, we were unable to replicate the mentioned exception based on the provided call stack. We have tried various cases in order to replicate the issue, including using Doughnut Series, Pie Series, and RadialBar Series. We also tried using DataLabelSettings with and without the dataLabelMapper property, as well as using the builder property in the DataLabelSettings. Additionally, we utilized properties such as angle, labelIntersectAction, labelAlignment, overFlowMode, useSeriesColor and labelPosition.

We recommend that you share some additional details regarding the specific case in which the exception occurs or provide steps to reproduce the mentioned exception in the attached sample below. With this additional information, it will be very helpful for us to provide the best possible solution from our end.

Regards, Hari Hara Sudhan. K. _490013.zip

muezz commented 9 months ago

@sfHariHaraSudhan I am also getting this error. In my case, it was a radial chart in a page view. If I double click to drag the page and go the the next one, I get this error. It only happens if I click inside the chart (or the region occupied by it).

Keep in mind that in iOS simulators, to drag something, you have to click/tab your touchpad twice while keeping your finger on the touchpad after the second click. Then you can drag your finger. To release the drag, you have to click/tap once more. This late initialisation error happens as soon as this last click/tap happens.

I have also tried on a real device (iPhone 12 Pro) and with that, there is no need for click/tap. I just dragged normally and I still got this error.

This is the exception with the stack trace:

════════ Exception caught by gesture library ═══════════════════════════════════
The following LateError was thrown while dispatching a pointer event:
LateInitializationError: Field 'labelRect' has not been initialized.

When the exception was thrown, this was the stack:
#0      ChartPoint.labelRect (package:syncfusion_flutter_charts/src/circular_chart/renderer/chart_point.dart)
#1      _showTrimmedDataLabelTooltip (package:syncfusion_flutter_charts/src/circular_chart/base/circular_area.dart:774:41)
circular_area.dart:774
#2      CircularArea._onPointerUp (package:syncfusion_flutter_charts/src/circular_chart/base/circular_area.dart:256:7)
circular_area.dart:256
#3      CircularArea.build.<anonymous closure>.<anonymous closure> (package:syncfusion_flutter_charts/src/circular_chart/base/circular_area.dart:76:54)
circular_area.dart:76
#4      RenderPointerListener.handleEvent (package:flutter/src/rendering/proxy_box.dart:3068:27)
proxy_box.dart:3068
#5      GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:468:22)
binding.dart:468
#6      RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:439:11)
binding.dart:439
#7      GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:413:7)
binding.dart:413
#8      GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:376:5)
binding.dart:376
#9      GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:323:7)
binding.dart:323
#10     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:292:9)
binding.dart:292
#11     _invoke1 (dart:ui/hooks.dart:328:13)
hooks.dart:328
#12     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:410:7)
platform_dispatcher.dart:410
#13     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
hooks.dart:262

Event: PointerUpEvent#2d277(position: Offset(405.7, 583.3))
    position: Offset(405.7, 583.3)
Target: RenderPointerListener#57717
    needs compositing
    parentData: <none> (can use size)
    constraints: BoxConstraints(w=368.0, h=263.4)
    size: Size(368.0, 263.4)
    behavior: deferToChild
    listeners: down, move, up
════════════════════════════════════════════════════════════════════════════════
PreethikaSelvam commented 9 months ago

Hi @woyl,

The reported issue is already fixed, and the fix is published in the below version. Therefore, we kindly request that you upgrade the syncfusion_flutter_charts package to the latest version below to avoid this issue.

Version: https://pub.dev/packages/syncfusion_flutter_charts/versions/24.2.4+3

Regards,

Preethika Selvam.