Created with <3 with dartpad.dev.
Created
September 21, 2023 06:32
-
-
Save maks/f964e83a61ce3a8c4e94d567ddf8da8e to your computer and use it in GitHub Desktop.
lively-osmium-3954
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
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