I'm using multiprovider in my application. Provider works perfectly, it stores the data and it provides perfect events when anything gets changed.
Now, I've this scenario in my app ->
User 1 loggedIn. Now when I'm adding a second account in the same login(Like Gmail - Multi-Account) providers are returning me with older values.
I tried to search for resetting values of providers but couldn't able to find anything related to it.
Tried things but didn't work:
Provider.of<LoginProvider>(context).dispose();
To update a Provider value you can call it with .value()
constructor and use a state-dependant variable.
class SomeWidgetState extends State<SomeWidget> {
Logins logins = [];
void addLogin(Login newLogin) {
setState((){
logins = [...logins, newLogin];
});
}
@override
Widget build(BuildContext context) {
return Provider.value(
value: logins,
child: OtherWidget(),
);
}
When calling addLogin
the registered value in Provider will be updated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With