Created with <3 with dartpad.dev.
Created
February 17, 2023 22:32
-
-
Save guitoof/cd4fc6294db6ec4a7864961840ab0ace to your computer and use it in GitHub Desktop.
crimson-tulip-4412
This file contains hidden or 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
enum EpisodeReadingStatus { | |
notStarted, | |
inProgress, | |
completed; | |
factory EpisodeReadingStatus.fromProgress(double progress) { | |
if (progress == 0) return EpisodeReadingStatus.notStarted; | |
else if (progress < 1) return EpisodeReadingStatus.inProgress; | |
else return EpisodeReadingStatus.completed; | |
} | |
} | |
void main() { | |
print(EpisodeReadingStatus.fromProgress(0)); | |
print(EpisodeReadingStatus.fromProgress(0.3)); | |
print(EpisodeReadingStatus.fromProgress(0.6)); | |
print(EpisodeReadingStatus.fromProgress(0.75)); | |
print(EpisodeReadingStatus.fromProgress(1)); | |
print(EpisodeReadingStatus.fromProgress(1.4)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment