Created
December 3, 2020 16:46
-
-
Save daninfpj/a29c0a94d4a894d0a9015ae6bd343382 to your computer and use it in GitHub Desktop.
Enum extension
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 TransferStatus { | |
created, | |
authorizing, | |
sending, | |
verifying, | |
pending, | |
refunded, | |
success, | |
error, | |
} | |
extension TransferStatusExtension on TransferStatus { | |
static const processingStatuses = [ | |
TransferStatus.pending, | |
TransferStatus.authorizing | |
]; | |
bool get isProcessing { | |
return processingStatuses.contains(this); | |
} | |
} | |
void main() { | |
const status = TransferStatus.pending; | |
if (status.isProcessing) { | |
print("Processing"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment