Created
February 17, 2022 11:59
-
-
Save kikuchy/55bf5894f7c777d5f20e163f864d1631 to your computer and use it in GitHub Desktop.
Enum live template with when method like freezed sealed classes
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
enum $NAME$ { | |
$V1$, | |
$V2$, | |
} | |
extension $NAME$X on $NAME$ { | |
T when<T>({ | |
required T Function() $V1$, | |
required T Function() $V2$, | |
}) { | |
switch (this) { | |
case $NAME$.$V1$: | |
return $V1$(); | |
case $NAME$.$V2$: | |
return $V2$(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Each variable settings