Note class should not be sortable

There are various different methods of sorting an note.
This commit is contained in:
Vishesh Handa
2020-03-06 20:14:21 +01:00
parent d7265ec69b
commit 56d8f635eb
2 changed files with 4 additions and 18 deletions

View File

@ -18,7 +18,7 @@ enum NoteLoadState {
NotExists,
}
class Note with ChangeNotifier implements Comparable<Note> {
class Note with ChangeNotifier {
NotesFolder parent;
String _filePath;
@ -232,19 +232,4 @@ class Note with ChangeNotifier implements Comparable<Note> {
String toString() {
return 'Note{filePath: $_filePath, created: $created, modified: $modified, data: $_data}';
}
@override
int compareTo(Note other) {
if (other == null) {
return -1;
}
var dt = modified ?? created ?? fileLastModified;
var otherDt = other.modified ?? other.created ?? other.fileLastModified;
if (dt == null || otherDt == null) {
return _filePath.compareTo(other._filePath);
}
return dt.compareTo(otherDt);
}
}

View File

@ -56,8 +56,9 @@ void main() {
loadedNotes.add(note);
});
loadedNotes.sort();
notes.sort();
var sortFn = (Note n1, Note n2) => n1.filePath.compareTo(n2.filePath);
loadedNotes.sort(sortFn);
notes.sort(sortFn);
expect(loadedNotes, notes);