Describe the bug
A consumer widget fails to watch the change of the returned value of a FutureProvider when the initial value is an empty list
To Reproduce
please excuse the sudo code
// this returns an empty list initially
final todoProvider = FutureProvider.autoDispose((ref) async {
final dio = ref.read(dioProvider);
final response = await dio.get('/todo');
final todoList = response.data['data']['todo'] as List<dynamic>;
return todoList;
});
class TodoWidget extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
// todoList updates when the initial `todoList` is not empty, but it does not update when the initial `todoList` is empty
final todoList = ref.watch(todoProvider);
return Scaffold(
IconButton(
onPressed: () async {
await createTodo();
ref.refresh(todoProvider);
}
)
)
}
Expected behavior
The returned value should be watched and updated
Describe the bug A consumer widget fails to watch the change of the returned value of a FutureProvider when the initial value is an empty list
To Reproduce please excuse the sudo code
Expected behavior The returned value should be watched and updated