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

How to auto reset the value of Provider ?? This is the ,measure issue i find on Provider, Can you please suggest me how to handle reset all value inside TestProvider without create method manually to reset any value?? #880

Open
DeepakYiron opened this issue Jun 27, 2024 · 0 comments
Assignees
Labels
bug Something isn't working needs triage

Comments

@DeepakYiron
Copy link

I just create a provider with one bool var which is used to check and uncheck the checkbox widget state.

class TestProvider extends ChangeNotifier {
bool isChecked=false;
onChangeCheckBoxVal(val){
isChecked=val;
notifyListeners();
}
}

Here is my code of UI

Consumer(builder: (context, provider, child){
return Checkbox(value: provider.isChecked, onChanged: (val){
provider.onChangeCheckBoxVal(val);
}),

})

See Here is isChecked =false by-default
i Navigate to this screen from some other screen and changed the state of checkbox (now its true)

Now My concern is if go back to previous screen and then re enter in this checkbox screen then i found the checkbox value is true.

how can i reset the the provider all value when screen is no more needed and disposed.

I have tried the solution with creating a method to reset value , but thats not the right approach to reset manually.
Please suggest me how to handle this senario,
its just a example of one checkbox. but in my app there are 100s of fields and i am going to reset all manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

2 participants