Skip to content

Commit 1431e57

Browse files
committed
Fix sorting issues with multiple items created at the same time.
1 parent 5c2b6cb commit 1431e57

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

demos/supabase-todolist/lib/models/todo_list.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class TodoList {
3737
/// Watch all lists.
3838
static Stream<List<TodoList>> watchLists() {
3939
// This query is automatically re-run when data in "lists" or "todos" is modified.
40-
return db.watch('SELECT * FROM lists ORDER BY created_at').map((results) {
40+
return db
41+
.watch('SELECT * FROM lists ORDER BY created_at, id')
42+
.map((results) {
4143
return results.map(TodoList.fromRow).toList(growable: false);
4244
});
4345
}
@@ -71,7 +73,7 @@ class TodoList {
7173
/// Watch items within this list.
7274
Stream<List<TodoItem>> watchItems() {
7375
return db.watch(
74-
'SELECT * FROM todos WHERE list_id = ? ORDER BY created_at DESC',
76+
'SELECT * FROM todos WHERE list_id = ? ORDER BY created_at DESC, id',
7577
parameters: [id]).map((event) {
7678
return event.map(TodoItem.fromRow).toList(growable: false);
7779
});

0 commit comments

Comments
 (0)