Skip to content

Instantly share code, notes, and snippets.

@shilangyu
Created November 21, 2022 15:38
Show Gist options
  • Save shilangyu/b0c8c65cceb650ee7d968701e76cbd01 to your computer and use it in GitHub Desktop.
Save shilangyu/b0c8c65cceb650ee7d968701e76cbd01 to your computer and use it in GitHub Desktop.
class Event {}
class CoolEvent extends Event {}
class EventHandler<T extends Event> {}
extension<T extends Event> on EventHandler<T> {
Type get eventType => T;
}
void func<T extends Event>(EventHandler<T> e) {
print(e.eventType);
print(e.runtimeType);
print(e.eventType == CoolEvent);
}
void main() {
final EventHandler<Event> a = EventHandler<CoolEvent>();
func(a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment