Last active
March 8, 2020 03:54
-
-
Save xinthink/1f98ec3bca2fe7e8af8c161ffd9ad827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NoteStateX on NoteState { | |
/// Checks if a note in this state can be edited. | |
bool get canEdit => this < NoteState.deleted; | |
/// Returns true if this state is preceding to the other one. | |
bool operator <(NoteState other) => (this?.index ?? 0) < (other?.index ?? 0); | |
/// Message describes the state transition. | |
String get message { | |
switch (this) { | |
case NoteState.deleted: | |
return 'Note moved to trash'; | |
... | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment