Skip to content

Instantly share code, notes, and snippets.

@ttlg
Created November 21, 2021 12:41
Show Gist options
  • Save ttlg/4da3cb9ce4cac879ac797ab6a6e8a291 to your computer and use it in GitHub Desktop.
Save ttlg/4da3cb9ce4cac879ac797ab6a6e8a291 to your computer and use it in GitHub Desktop.
final sortedTodoListState = StateProvider<List<Todo>?>((ref) {
final List<Todo>? todoList = ref.watch(_todoListState);
if (ref.watch(_sortOrderState) == SortOrder.ASC) {
todoList?.sort((a, b) => a.timestamp.compareTo(b.timestamp));
} else {
todoList?.sort((a, b) => b.timestamp.compareTo(a.timestamp));
}
return todoList;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment