I have a FutureProvider with a List of items. How can I update an item in this list without a refresh the provider?
I have a FutureProvider with a List of items. How can I update an item in this list without a refresh the provider?
You should use a StateNotifierProvider for your list like this:
final listProvider = StateNotifierProvider<ListItem, dynamic>((ref) {
return ListItem([]);
});
class ListItem extends StateNotifier<dynamic> {
ListItem(List<dynamic> items) : super(items);
void update(dynamic item) {
// Your update logic. You have access to the use with 'state' variable
}
}
Before that you populate the listProvider with your future response. Also you should change the dynamic type to your object type on the list