Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

OrdinalComboChart and LineChart do not work in release mode, when placed inside MaterialApp (in v0.5 not in v0.4) #177

Open
TomOerlemans opened this issue Nov 25, 2018 · 1 comment

Comments

@TomOerlemans
Copy link

TomOerlemans commented Nov 25, 2018

When using OrdinalComboChart or LineChart I noticed that they stop working when run in release mode and placed inside a MaterialApp widget. This is the error I get:

I/flutter (30490): The following RenderObject was being processed when the exception was fired:
I/flutter (30490):   ChartContainerRenderObject<String>#6aca1 NEEDS-PAINT
I/flutter (30490):   parentData: <none>
I/flutter (30490):   constraints: BoxConstraints(w=360.0, h=640.0)
I/flutter (30490):   semantic boundary
I/flutter (30490):   size: Size(0.0, 0.0)
I/flutter (30490): This RenderObject has no descendants.

And this is the code to reproduce the problem:

import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;

void main() {
  runApp(new OrdinalComboBarLineChart());
}

class OrdinalComboBarLineChart extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    List<charts.Series> seriesList = _createSampleData();

    return MaterialApp(
        home: Container(
            height: 205.0,
            width: 350.0,
            child: charts.OrdinalComboChart(seriesList,
                animate: false,
                defaultRenderer: charts.LineRendererConfig(
                    areaOpacity: 0.8, includeArea: true),
                customSeriesRenderers: [
                  new charts.LineRendererConfig(customRendererId: 'LineOne'),
                ])));
  }

  /// Create series list with multiple series
  List<charts.Series<OrdinalSales, String>> _createSampleData() {
    var categoryOne = [
      new OrdinalSales('0:00', 0),
      new OrdinalSales('12:00', 0),
      new OrdinalSales('23:59', 25),
    ];

    var lineOne = [
      new OrdinalSales('0:00', 30),
      new OrdinalSales('12:00', 15),
      new OrdinalSales('23:59', 7),
    ];

    final Color myRed = const Color(0xFFEB4141);
    final Color myDarkBackground = const Color(0xFF101926);

    return [
      new charts.Series<OrdinalSales, String>(
          id: 'CategoryOne',
          colorFn: (_, __) => charts.Color(
              r: myRed.red, g: myRed.green, b: myRed.blue, a: myRed.alpha),
          domainFn: (OrdinalSales sales, _) => sales.year,
          measureFn: (OrdinalSales sales, _) => sales.sales,
          data: categoryOne),
      new charts.Series<OrdinalSales, String>(
          id: 'LineOne ',
          colorFn: (_, __) => charts.Color(
              r: myDarkBackground.red,
              g: myDarkBackground.green,
              b: myDarkBackground.blue,
              a: myDarkBackground.alpha),
          domainFn: (OrdinalSales sales, _) => sales.year,
          measureFn: (OrdinalSales sales, _) => sales.sales,
          data: lineOne)
        ..setAttribute(charts.rendererIdKey, 'LineOne'),
    ];
  }
}

/// Sample ordinal data type.
class OrdinalSales {
  final String year;
  final int sales;
  OrdinalSales(this.year, this.sales);
}

I am using charts_flutter: ^0.5.0.

@TomOerlemans TomOerlemans changed the title OrdinalComboChart throws exception in release mode OrdinalComboChart and Line chart do not work in release mode, when placed inside MaterialApp Dec 6, 2018
@TomOerlemans TomOerlemans changed the title OrdinalComboChart and Line chart do not work in release mode, when placed inside MaterialApp OrdinalComboChart and LineChart do not work in release mode, when placed inside MaterialApp Dec 6, 2018
@TomOerlemans
Copy link
Author

So I am far from a great programmer (and thus I don't really understand what is going on), but I just discovered that this issue does not exist when I use charts_flutter: ^0.4.0, as opposed to charts_flutter: ^0.5.0. So it seems like the issue got introduced with the latest update.

@TomOerlemans TomOerlemans changed the title OrdinalComboChart and LineChart do not work in release mode, when placed inside MaterialApp OrdinalComboChart and LineChart do not work in release mode, when placed inside MaterialApp (in v5 not in v4) Dec 6, 2018
@TomOerlemans TomOerlemans changed the title OrdinalComboChart and LineChart do not work in release mode, when placed inside MaterialApp (in v5 not in v4) OrdinalComboChart and LineChart do not work in release mode, when placed inside MaterialApp (in v0.5 not in v0.4) Dec 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant