Reputation: 63
I have a list of a few things and each has its own ID. I want to pass that certain ID to the provider whenever it's clicked. But as of now, when I click on ITEM ONE in the list for the first time, the ID of ITEM ONE is passed to the provider, but when I click again on a different item in the list the ID of that item is not updated in the provider. I want to know, how can I update the data of the provider every time a new item is clicked.
here are my codes:
onTap: () async {
Provider.of<providerFile>(context, listen: false).setdataID(DataID);
Navigator.push(context, MaterialPageRoute(builder: (context) => NextPageHome(DataID: DataID)));
},
String DataID = '';
void setdataID(String pin) {
if (DataID.isEmpty) {
DataID = pin;
notifyListeners();
}
}
Thanks, programmers.
Upvotes: 1
Views: 167