Created
July 25, 2024 13:07
-
-
Save evaisse/8a5fd3c295deb4c8d81ba6be5b94b6f4 to your computer and use it in GitHub Desktop.
dart sealed class and unstructuring of switch case in pattern matching
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 ScoreLevel { | |
rookie, | |
maestro | |
} | |
sealed class MyState { | |
} | |
class SuccessState extends MyState { | |
final int score; | |
final ScoreLevel level; | |
SuccessState({ required this.score, required this.level}); | |
} | |
class SomeErrorsState extends MyState { | |
final Error error; | |
final String? maybeResultAnyway; | |
SomeErrorsState({ required this.error, required this.maybeResultAnyway}); | |
} | |
bool _isThatSomeGoodNews(MyState state) { | |
} | |
void main() { | |
for (int i = 0; i < 10; i++) { | |
print('hello ${i + 1}'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment