Skip to content

Instantly share code, notes, and snippets.

@evaisse
Created July 25, 2024 13:07
Show Gist options
  • Save evaisse/8a5fd3c295deb4c8d81ba6be5b94b6f4 to your computer and use it in GitHub Desktop.
Save evaisse/8a5fd3c295deb4c8d81ba6be5b94b6f4 to your computer and use it in GitHub Desktop.
dart sealed class and unstructuring of switch case in pattern matching
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