diegoveloper / flutter_percent_indicator

Flutter percent indicator library
BSD 2-Clause "Simplified" License
677 stars 206 forks source link

Cannot get size from a render object that has not been through layout. #187

Closed labarefo closed 1 year ago

labarefo commented 1 year ago

I put LinearPercentIndicator > ListTile in a stateless widget Complete message

The size of this render object has not yet been determined because this render object has not yet been through layout, which typically means that the size getter was called too early in the pipeline (e.g., during the build phase) before the framework has determined the size and position of the render objects during layout.

The size getter was called for the following element: CustomPaint-[GlobalKey#2fb73] renderObject: RenderCustomPaint#99a01 NEEDS-LAYOUT NEEDS-PAINT The render object from which the size was to be obtained was: RenderCustomPaint#99a01 NEEDS-LAYOUT NEEDS-PAINT ... parentData: not positioned; offset=Offset(0.0, 0.0) ... constraints: MISSING ... size: MISSING ... painter: _LinearPainter#d92a2() When the exception was thrown, this was the stack:

0 Element.size. (package:flutter/src/widgets/framework.dart:4195:9)

1 Element.size (package:flutter/src/widgets/framework.dart:4227:6)

2 _LinearPercentIndicatorState.initState.. (package:percent_indicator/linear_percent_indicator.dart:165:59)

3 State.setState (package:flutter/src/widgets/framework.dart:1114:30)

4 _LinearPercentIndicatorState.initState. (package:percent_indicator/linear_percent_indicator.dart:164:9)

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

6 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113:9)

7 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1015:5)

8 _invoke (dart:ui/hooks.dart:148:13)

9 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:318:5)

10 _drawFrame (dart:ui/hooks.dart:115:31)

====================================================================================================

diegoveloper commented 1 year ago

Add a SizedBox(width with a fixed width at the top of LinearPercentIndicator