Skip to content

Instantly share code, notes, and snippets.

@eernstg
Created June 13, 2022 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eernstg/27945e73fc4fda552d1c341b9895d561 to your computer and use it in GitHub Desktop.
Save eernstg/27945e73fc4fda552d1c341b9895d561 to your computer and use it in GitHub Desktop.
enum Key {
key1,
key2;
T mapFor<T>({
required T Function() key1,
required T Function() key2,
}) {
switch (this) {
case Key.key1: return key1();
case Key.key2: return key2();
}
}
}
void main() {
Key key = Key.key1;
key.mapFor(
key1: () => print('This was key1'),
key2: () => print('This was key2'),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment