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

Update the maps value on setstate #64

Open
atta1234 opened this issue Feb 21, 2021 · 1 comment
Open

Update the maps value on setstate #64

atta1234 opened this issue Feb 21, 2021 · 1 comment

Comments

@atta1234
Copy link

atta1234 commented Feb 21, 2021

this how i defined the pie chart map, when page load i want to set the values,0

 Map<String, double> dataMap = {
    "Income": 0,
    "Expenditure": 0,
  };

then on button press, i want update the chart value,

  child: RaisedButton(
                              onPressed: () async {
                                      setState(() {
                                        Map<String, double> dataMap = {
                                          "Income": 75,
                                          "Expenditure": 25,
                                        };
                                      
                                      });
                                    },

How to solve this issue?

@apgapg apgapg changed the title Hello, i want to update the maps value on setstate Update the maps value on setstate Feb 22, 2021
@apgapg
Copy link
Owner

apgapg commented Feb 22, 2021

@atta1234 You can simply assign a new map to dataMap on setstate. The pie chart would automatically update itself upon changing data map

onPressed: () async {
                                      setState(() {
                                        Map<String, double> dataMap = {
                                          "Income": 75,
                                          "Expenditure": 25,
                                        };
                                      this.dataMap=dataMap; // This line would cause your data map field variable to update
                                      
                                      });
                                    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants