Skip to content

Instantly share code, notes, and snippets.

@maks
Created September 21, 2023 06:32
Show Gist options
  • Save maks/f964e83a61ce3a8c4e94d567ddf8da8e to your computer and use it in GitHub Desktop.
Save maks/f964e83a61ce3a8c4e94d567ddf8da8e to your computer and use it in GitHub Desktop.
lively-osmium-3954
typedef Callback = Object Function();
void main() async {
final res = request(false);
final mesg = switch (res) {
OkResponse() => "houston we are ok",
ErrResponse() => "houston we have a problem"
};
print(mesg);
}
Response request(bool stirOxygen) {
if (stirOxygen) {
return ErrResponse();
} else {
return OkResponse();
}
}
sealed class Response {}
class OkResponse extends Response{}
class ErrResponse extends Response{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment