title: Flutter: Build scheduled during frame error using Provider package
body: <p>Hey guys I need help in de-bugging what is going on. I get the following error (below). I am new to flutter and any help would be appreciated. What I am trying to do here is that anytime someone double clicks on the chart (using the cross hair functionality), it creates a new data point and re-draws the chart. Thank you!</p>
  
  <p>Error:
  ════════ Exception caught by foundation library ════════════════════════════════
  The following assertion was thrown while dispatching notifications for PlotData:
  Build scheduled during frame.
  While the widget tree was being built, laid out, and painted, a new frame was scheduled to rebuild the widget tree.</p>
  
  <p>All my Code:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:provider/provider.dart';
  import 'package:syncfusion_flutter_charts/charts.dart';
  
  void main() {
    runApp(MyApp());
  }
  
  class MyApp extends StatelessWidget {
  // This tokwidget is the root of your application.
    @override
    Widget build(BuildContext context) {
      return MultiProvider(
        providers: [
          ChangeNotifierProvider(create: (_) =&gt; PlotData()),
        ],
        child: Consumer&lt;PlotData&gt;(builder: (context, plotData, _) {
          return MaterialApp(
            home: FirstPage(),
          );
        }),
      );
    }
  }
  
  class SalesData {
    SalesData(this.year, this.sales);
    final String year;
    final double sales;
  }
  
  class PlotData extends ChangeNotifier {
    List&lt;SalesData&gt; data = [
      SalesData('Jan', 35),
      SalesData('Feb', 28),
      SalesData('Mar', 34),
      SalesData('Apr', 32),
      SalesData('May', 40)
    ];
    void addData(List selectedPoint) {
      print("Current Length of data: " + data.length.toString());
      List&lt;SalesData&gt; addPoint = [
        SalesData(selectedPoint[0], double.parse(selectedPoint[1]))
      ];
      data = data + addPoint;
      print("Now Data has Length of: " + data.length.toString());
      notifyListeners();
    }
  
    List&lt;SalesData&gt; get allData =&gt; data;
  }
  
  class VolumeChart extends StatelessWidget {
  // Holds the selected points by the user
    List selectedPoint = [];
  //VolumeChart(this.data);
    @override
    Widget build(BuildContext context) {
      return SfCartesianChart(
        onCrosshairPositionChanging: (CrosshairRenderArgs args) {
  // Crosshair calls this function twice, once for the x,y values respectively
  // we capture the full data point string in a list that empties itself when new points are selected
          if (selectedPoint.length == 2) {
            selectedPoint = [];
          }
          selectedPoint.add(args.value); // save the coordinates of the point
  // @TODO delete this later, used for prinitng coordinates
          if (selectedPoint.length == 2) {
            Provider.of&lt;PlotData&gt;(context, listen: false).addData(selectedPoint);
  //print(selectedPoint.toString());
          }
        },
  // Enables the tooltip for all the series in chart
        crosshairBehavior: CrosshairBehavior(
            activationMode: ActivationMode.doubleTap, enable: true),
  // Initialize category axis
        primaryXAxis: CategoryAxis(),
        series: &lt;ChartSeries&gt;[
  // Initialize line series
          LineSeries&lt;SalesData, String&gt;(
  // Enables the tooltip for individual series
              enableTooltip: true,
              dataSource: Provider.of&lt;PlotData&gt;(context, listen: true).allData,
              xValueMapper: (SalesData sales, _) =&gt; sales.year,
              yValueMapper: (SalesData sales, _) =&gt; sales.sales),
        ],
      );
    }
  }
  
  class FirstPage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return Column(
        children: &lt;Widget&gt;[
          VolumeChart(),
        ],
      );
    }
  }
  
  </code></pre>