Skip to content

Instantly share code, notes, and snippets.

@ashphy
Created July 25, 2022 10:11
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 ashphy/6191133153e76d38d8b0bb0893a445c5 to your computer and use it in GitHub Desktop.
Save ashphy/6191133153e76d38d8b0bb0893a445c5 to your computer and use it in GitHub Desktop.
Dart2.17 enhanced-enums implements interface sample
abstract class Abstract {
void foo();
}
enum Categoly implements Abstract {
sample1,
sample2;
@override
foo() { print(this); }
}
enum Division implements Abstract {
sample1,
sample2;
@override
foo() { print(this); }
}
void test<T extends Abstract>(T type) {
type.foo();
}
void main() {
test(Categoly.sample1);
test(Division.sample2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment