Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception: type 'RenderFlex' is not a subtype of type 'RenderChartPlotArea?' in type cast #2236

Open
vecharm opened this issue Dec 31, 2024 · 1 comment
Labels
charts Charts component waiting for customer response Cannot make further progress until the customer responds.

Comments

@vecharm
Copy link

vecharm commented Dec 31, 2024

Bug description

When I upgraded from Flutter3.19.3 to 3.24.5 and syncfusion-lutter_charts from 23.1.36 to 27.2.4, an error occurred. Due to issues with other dependent libraries, my Flutter had to be upgraded to 3.24.5. As a result of upgrading Flutter, syncfusion-lutter_charts also had to be upgraded to 27.2.4. On 23.1.36, it ran normally. I have been searching for many days without finding a solution. Do you have a solution?

Steps to reproduce

Flutter3.19.3 upgraded to 3.24.5, syncfusion-lutter_charts upgraded from 23.1.36 to 27.2.4

Code sample

Code sample
SplineAreaSeries(
        animationDelay: Const.chartAnimDelay,
        dataSource: chartData.lines[it] as List<Point>,
        onRendererCreated: (controller) => controllers[yTitle.title!] = controller,
        xValueMapper: (Point it, _) => it.x!,
        yValueMapper: (Point it, _) => it.y!,
        markerSettings: const MarkerSettings(isVisible: false),
        splineType: SplineType.clamped,
        borderColor: yTitle.color,
        borderWidth: 2,
        gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [yTitle.color.withOpacity(0.4), yTitle.color.withOpacity(0.01)]),
        yAxisName: yTitle.position,
        name: yTitle.title,
      );

Screenshots or Video

Screenshots / Video demonstration image image image

Stack Traces

Stack Traces
E/flutter (19948): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'RenderFlex' is not a subtype of type 'RenderChartPlotArea?' in type cast
E/flutter (19948): #0      ChartSeriesRenderer.parent (package:syncfusion_flutter_charts/src/charts/series/chart_series.dart:838:51)
E/flutter (19948): #1      CartesianSeriesRenderer.parent (package:syncfusion_flutter_charts/src/charts/series/chart_series.dart:3333:13)
E/flutter (19948): #2      ChartSeriesRenderer._initSelection (package:syncfusion_flutter_charts/src/charts/series/chart_series.dart:1321:9)
E/flutter (19948): #3      ChartSeriesRenderer.attach (package:syncfusion_flutter_charts/src/charts/series/chart_series.dart:1286:5)
E/flutter (19948): #4      CartesianSeriesRenderer.attach (package:syncfusion_flutter_charts/src/charts/series/chart_series.dart:3494:11)
E/flutter (19948): #5      RenderObject.adoptChild (package:flutter/src/rendering/object.dart:1841:13)
E/flutter (19948): #6      ContainerRenderObjectMixin.insert (package:flutter/src/rendering/object.dart:4324:5)
E/flutter (19948): #7      MultiChildRenderObjectElement.insertRenderObjectChild (package:flutter/src/widgets/framework.dart:6974:18)
E/flutter (19948): #8      RenderObjectElement.attachRenderObject (package:flutter/src/widgets/framework.dart:6732:35)
E/flutter (19948): #9      RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6597:5)
E/flutter (19948): #10     SlottedRenderObjectElement.mount (package:flutter/src/widgets/slotted_render_object_widget.dart:248:11)
E/flutter (19948): #11     Element.inflateWidget (package:flutter/src/widgets/framework.dart:4468:16)
E/flutter (19948): #12     Element.updateChild (package:flutter/src/widgets/framework.dart:3963:18)
E/flutter (19948): #13     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
E/flutter (19948): #14     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5780:11)
E/flutter (19948): #15     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
E/flutter (19948): #16     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:5599:5)
E/flutter (19948): #17     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5771:11)
E/flutter (19948): #18     ComponentElement.mount (package:flutter/src/widgets/framework.dart:5593:5)
E/flutter (19948): #19     Element.inflateWidget (package:flutter/src/widgets/framework.dart:4468:16)
E/flutter (19948): #20     Element.updateChild (package:flutter/src/widgets/framework.dart:3957:20)
E/flutter (19948): #21     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
E/flutter (19948): #22     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
E/flutter (19948): #23     StatelessElement.update (package:flutter/src/widgets/framework.dart:5693:5)
E/flutter (19948): #24     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
E/flutter (19948): #25     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
E/flutter (19948): #26     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5780:11)
E/flutter (19948): #27     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
E/flutter (19948): #28     BuildScope._tryRebuild (package:flutter/src/widgets/framework.dart:2693:15)
E/flutter (19948): #29     BuildScope._flushDirtyElements (package:flutter/src/widgets/framework.dart:2752:11)
E/flutter (19948): #30     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:3048:18)
E/flutter (19948): #31     _LayoutBuilderElement._rebuildWithConstraints (package:flutter/src/widgets/layout_builder.dart:231:12)
E/flutter (19948): #32     RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:2719:59)
E/flutter (19948): #33     PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:1098:15)
E/flutter (19948): #34     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:2719:14)
E/flutter (19948): #35     RenderConstrainedLayoutBuilder.rebuildIfNecessary (package:flutter/src/widgets/layout_builder.dart:278:5)
E/flutter (19948): #36     _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:369:5)
E/flutter (19948): #37     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2446:7)
E/flutter (19948): #38     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1052:18)
E/flutter (19948): #39     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1065:15)
E/flutter (19948): #40     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:602:23)
E/flutter (19948): #41     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1164:13)
E/flutter (19948): #42     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:468:5)
E/flutter (19948): #43     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1397:15)
E/flutter (19948): #44     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1318:9)
E/flutter (19948): #45     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1176:5)
E/flutter (19948): #46     _rootRun (dart:async/zone.dart:1399:13)
E/flutter (19948): #47     _CustomZone.run (dart:async/zone.dart:1301:19)
E/flutter (19948): #48     _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
E/flutter (19948): #49     _invoke (dart:ui/hooks.dart:314:10)
E/flutter (19948): #50     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:419:5)
E/flutter (19948): #51     _drawFrame (dart:ui/hooks.dart:283:31)

On which target platforms have you observed this bug?

Android

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.5, on macOS 14.5 23F79 darwin-arm64, locale zh-Hans-CN)
    • Flutter version 3.24.5 on channel stable at /Users/vecharm/fvm/versions/3.24.5
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (7 周前), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3
@VijayakumarMariappan VijayakumarMariappan added charts Charts component open Open labels Jan 2, 2025
@KompelliSravanSyncfusion
Copy link

KompelliSravanSyncfusion commented Jan 3, 2025

Hi vecharm,

We have checked the mentioned issue and tried to replicate it in SfCartesianChart with version 27.2.4 and with latest version 28.1.37.

  1. Tested the reported details in Android, Windows and Web platforms.
  2. Tested Flutter Charts with 27.2.4, 28.1.37 and tested the SplineAreaSeries with the provided onRendererCreated callback.

However, we were unable to reproduce it on our end. Please check the attached sample, and if you are still experiencing the issue, we request that you replicate it in the attached sample and provide us with more details regarding the specific scenario in which you are encountering this issue. This will help us to assist you more effectively.

class SplineAreaCharts extends StatefulWidget {
  const SplineAreaCharts({super.key});

  @override
  State<SplineAreaCharts> createState() => _SplineAreaChartsState();
}

class _SplineAreaChartsState extends State<SplineAreaCharts> {
  late Map<String, ChartSeriesController> controllers;
  final List<Point> chartData = [
    Point(0, 3),
    Point(1, 5),
    Point(2, 2),
    Point(3, 6),
    Point(4, 4),
  ];

  @override
  void initState() {
    super.initState();
    controllers = {};
  }

  @override
  Widget build(BuildContext context) {
    final yTitle = ChartTitleData('Sales', Colors.blue, 'SecondaryYAxis');
    return Scaffold(
      appBar: AppBar(title: const Text('Spline Area Chart Example')),
      body: SfCartesianChart(
        primaryXAxis: NumericAxis(),
        primaryYAxis: NumericAxis(),
        axes: <ChartAxis>[
          NumericAxis(
            name: 'SecondaryYAxis',
            opposedPosition: true,
            title: AxisTitle(text: yTitle.title),
          ),
        ],
        series: <SplineAreaSeries>[
          SplineAreaSeries<Point, double>(
            animationDelay: 500,
            dataSource: chartData,
            xValueMapper: (Point point, _) => point.x!,
            yValueMapper: (Point point, _) => point.y!,
            splineType: SplineType.clamped,
            borderColor: yTitle.color,
            borderWidth: 2,
            gradient: LinearGradient(
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              colors: [
                yTitle.color.withOpacity(0.4),
                yTitle.color.withOpacity(0.01),
              ],
            ),
            markerSettings: const MarkerSettings(isVisible: false),
            yAxisName: yTitle.position,
            name: yTitle.title,
            onRendererCreated: (ChartSeriesController controller) {
              controllers[yTitle.title] = controller;
            },
          ),
        ],
      ),
    );
  }
}

class Point {
  Point(this.x, this.y);
  final double? x;
  final double? y;
}

class ChartTitleData {
  ChartTitleData(this.title, this.color, this.position);
  final String title;
  final Color color;
  final String position;
}

sample:
GH-2236.zip

Regards,
Kompelli Sravan Kumar.

@LavanyaGowtham2021 LavanyaGowtham2021 added waiting for customer response Cannot make further progress until the customer responds. and removed open Open labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
charts Charts component waiting for customer response Cannot make further progress until the customer responds.
Projects
None yet
Development

No branches or pull requests

4 participants