flutter_circular_chart icon indicating copy to clipboard operation
flutter_circular_chart copied to clipboard

Issue since FLUTTER 2.0 upgrade

Open vigshrav opened this issue 4 years ago • 7 comments

Filename: .../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_circular_chart-0.1.0/lib/src/animated_circular_chart.dart

The below line is giving error while building app: line 121, 122: final AnimatedCircularChartState result = context .ancestorStateOfType(const TypeMatcher<AnimatedCircularChartState>());

ERROR: _The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.

  • 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/framework.dart'). Try correcting the name to the name of an existing method, or defining a method named 'ancestorStateOfType'. context.ancestorStateOfType(const TypeMatcher<AnimatedCircularChartState>());

FAILURE: Build failed with an exception.

  • Where: Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

  • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 20s Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 21.9s Exception: Gradle task assembleDebug failed with exit code 1_

vigshrav avatar Mar 05 '21 06:03 vigshrav

ancestorStateOfType has been depreciated. final AnimatedCircularChartState result = context.ancestorStateOfType(const TypeMatcher<AnimatedCircularChartState>()); becomes: final AnimatedCircularChartState result = context.findAncestorStateOfType<AnimatedCircularChartState>();

locrianmark avatar Mar 06 '21 16:03 locrianmark

I'd forked the project and published the fix @locrianmark https://pub.dev/packages/flutter_circular_chart_two

GusRodrigues86 avatar Mar 09 '21 01:03 GusRodrigues86

@GusRodrigues86 thanks. Gotta ditch this library asap, but your fork just saved me some time 🙌

shliama avatar Mar 09 '21 11:03 shliama

for a null safety version https://pub.dev/packages/awesome_circular_chart

xjodoin avatar Nov 11 '21 19:11 xjodoin

@xjodoin I am unable to update the chart using your fork. This is what I am getting when I run widget._chartKey.currentState!.updateData(nextData);

The following RenderObject was being processed when the exception was fired: _RenderColoredBox#19f3e relayoutBoundary=up11
...  parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
...  constraints: BoxConstraints(0.0<=w<=428.0, 0.0<=h<=Infinity)
...  size: MISSING
...  behavior: opaque
RenderObject: _RenderColoredBox#19f3e relayoutBoundary=up11
  parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
  constraints: BoxConstraints(0.0<=w<=428.0, 0.0<=h<=Infinity)
  size: MISSING
  behavior: opaque
...  child: RenderPadding#20c9c relayoutBoundary=up12 NEEDS-PAINT
...    parentData: <none> (can use size)
...    constraints: BoxConstraints(0.0<=w<=428.0, 0.0<=h<=Infinity)
...    size: MISSING
...    padding: EdgeInsets(0.0, 0.0, 0.0, 15.0)
...    textDirection: ltr
...    child: RenderFlex#af33f relayoutBoundary=up13 NEEDS-PAINT
...      parentData: offset=Offset(0.0, 0.0) (can use size)
...      constraints: BoxConstraints(0.0<=w<=428.0, 0.0<=h<=Infinity)
...      size: MISSING
...      direction: horizontal
...      mainAxisAlignment: center
...      mainAxisSize: max
...      crossAxisAlignment: center
...      textDirection: ltr
...      verticalDirection: down
...      child 1: RenderStack#9e3ec relayoutBoundary=up14 NEEDS-PAINT
...        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
...        constraints: BoxConstraints(unconstrained)
...        size: MISSING
...        alignment: AlignmentDirectional.topStart
...        textDirection: ltr
...        fit: loose
====================================================================================================

======== Exception caught by rendering library =====================================================
The following assertion was thrown during paint():
RenderBox was not laid out: _RenderColoredBox#f7d07 relayoutBoundary=up11
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1927 pos 12: 'hasSize'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

The relevant error-causing widget was: 
  Container Container:file:///Users/pratikbaid/Desktop/Work/FlutterDev/tg_final/lib/view/screens/tab_screen/tabs/collection_screen/collection_overview_screen.dart:311:27
When the exception was thrown, this was the stack: 
#2      RenderBox.size (package:flutter/src/rendering/box.dart:1927:12)
#3      _RenderColoredBox.paint (package:flutter/src/widgets/basic.dart:7526:9)
#4      RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2403:7)
#5      PaintingContext.paintChild (package:flutter/src/rendering/object.dart:189:13)
#6      RenderBoxContainerDefaultsMixin.defaultPaint (package:flutter/src/rendering/box.dart:2792:15)
#7      RenderFlex.paint (package:flutter/src/rendering/flex.dart:1078:7)
#8      RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2403:7)
#9      PaintingContext.paintChild (package:flutter/src/rendering/object.dart:189:13)
#10     RenderBoxContainerDefaultsMixin.defaultPaint (package:flutter/src/rendering/box.dart:2792:15)
#11     RenderFlex.paint (package:flutter/src/rendering/flex.dart:1078:7)
#12     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2403:7)
#13     PaintingContext.paintChild (package:flutter/src/rendering/object.dart:189:13)
#14     _RenderSingleChildViewport.paint.paintContents (package:flutter/src/widgets/single_child_scroll_view.dart:542:17)
#15     _RenderSingleChildViewport.paint (package:flutter/src/widgets/single_child_scroll_view.dart:556:9)
#16     RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2403:7)
#17     PaintingContext._repaintCompositedChild (package:flutter/src/rendering/object.dart:141:11)
#18     PaintingContext.repaintCompositedChild (package:flutter/src/rendering/object.dart:100:5)
#19     PipelineOwner.flushPaint (package:flutter/src/rendering/object.dart:973:29)
#20     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:499:19)
#21     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:883:13)
#22     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
#23     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1145:15)
#24     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1082:9)
#25     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:996:5)
#29     _invoke (dart:ui/hooks.dart:150:10)
#30     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:270:5)
#31     _drawFrame (dart:ui/hooks.dart:114:31)
(elided 5 frames from class _AssertionError and dart:async)
The following RenderObject was being processed when the exception was fired: _RenderColoredBox#f7d07 relayoutBoundary=up11
...  parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
...  constraints: BoxConstraints(0.0<=w<=428.0, 0.0<=h<=Infinity)
...  size: MISSING
...  behavior: opaque
RenderObject: _RenderColoredBox#f7d07 relayoutBoundary=up11
  parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
  constraints: BoxConstraints(0.0<=w<=428.0, 0.0<=h<=Infinity)
  size: MISSING
  behavior: opaque
...  child: RenderPadding#8cc4a relayoutBoundary=up12 NEEDS-PAINT
...    parentData: <none> (can use size)
...    constraints: BoxConstraints(0.0<=w<=428.0, 0.0<=h<=Infinity)
...    size: MISSING
...    padding: EdgeInsets(0.0, 0.0, 0.0, 15.0)
...    textDirection: ltr
...    child: RenderFlex#7a140 relayoutBoundary=up13 NEEDS-PAINT
...      parentData: offset=Offset(0.0, 0.0) (can use size)
...      constraints: BoxConstraints(0.0<=w<=428.0, 0.0<=h<=Infinity)
...      size: MISSING
...      direction: horizontal
...      mainAxisAlignment: center
...      mainAxisSize: max
...      crossAxisAlignment: center
...      textDirection: ltr
...      verticalDirection: down
...      child 1: RenderStack#fc142 relayoutBoundary=up14 NEEDS-PAINT
...        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
...        constraints: BoxConstraints(unconstrained)
...        size: MISSING
...        alignment: AlignmentDirectional.topStart
...        textDirection: ltr
...        fit: loose
====================================================================================================```

pratikbaid3 avatar Jan 11 '22 19:01 pratikbaid3

I don't think is related to the project. Did you try to set the explicitly the size https://stackoverflow.com/questions/64947936/flutter-errorfailed-assertion-line-1785-pos-12-hassize

xjodoin avatar Jan 11 '22 20:01 xjodoin

Set the mainAxisSize to minimum.

GusRodrigues86 avatar Jan 12 '22 00:01 GusRodrigues86