UI States for Local Data
Same as Week 4, local data also has 4 states:
return state.when(
loading: () => const Center(
child:
CircularProgressIndicator(),
),
data: (notes) {
if (notes.isEmpty) {
return const Center(
child: Text(
'No notes yet.',
),
);
}
return NotesList(notes);
},
error: (e, _) => ErrorView(
message: '$e',
onRetry: () => ref.invalidate(
notesProvider,
),
),
);
Offline extra: a dirty-count badge.