pie_chart icon indicating copy to clipboard operation
pie_chart copied to clipboard

How do I change PieChart when the data changes.

Open TugrulhanCinar opened this issue 5 years ago • 4 comments

I’m changing the data but piechart still doesn’t change even i use the setState, how can i do it?

TugrulhanCinar avatar Jul 27 '20 14:07 TugrulhanCinar

you manage to solve that?? :(

arnauete52 avatar Aug 07 '20 22:08 arnauete52

no i couldn't :( no i started using fl_chart 0.11.0

TugrulhanCinar avatar Aug 08 '20 00:08 TugrulhanCinar

I already added this method

  @override
  void didUpdateWidget(PieChart oldWidget) {
    initData();
    super.didUpdateWidget(oldWidget);
  }

Looks like this doesn't work. Will check it

apgapg avatar Sep 05 '20 04:09 apgapg

For the time being one can add ValueKey to pie chart like this: key: ValueKey(key),

and on changing data you can update the key like:

 RaisedButton(
            onPressed: () {
              setState(() {
                key = key + 1;
              });
            },
            child: Text("Reload".toUpperCase()),
          ),

apgapg avatar Sep 05 '20 04:09 apgapg