advanced_list_riverpod
advanced_list_riverpod copied to clipboard
Error when reload data
But when refresh data or change data with new length less than old length it show error Unhandled Exception: RangeError (index): Invalid value: Only valid value is 0: 1.
Can you give me an example code to understand the problem better. Because when I add refresh feature to the app, it worked with no error.
return RefreshIndicator( // Added this line
onRefresh: () async => ref.invalidate(listProvider), // Added this line
child: ListView.builder(
itemCount: ref.watch(listProvider.select((e) => e.length)),
itemBuilder: (_, index) {
return ProviderScope(
overrides: [indexProvider.overrideWith((_) => index)],
child: const _ListItem(),
);
},
), // Added this line
);