Skip to content

Instantly share code, notes, and snippets.

@dnys1
Created May 6, 2023 05:37
Show Gist options
  • Save dnys1/d0e678a63bbd01f1e9c07679ad1de410 to your computer and use it in GitHub Desktop.
Save dnys1/d0e678a63bbd01f1e9c07679ad1de410 to your computer and use it in GitHub Desktop.
lively-gorge-9708
class Serializable {
String toJson() => 'json';
}
void main() {
switch (Serializable() as dynamic) {
case dynamic(:final Object? Function() toJson):
print(toJson());
case _:
throw ArgumentError('Not serializable');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment