Created
November 21, 2022 15:38
-
-
Save shilangyu/b0c8c65cceb650ee7d968701e76cbd01 to your computer and use it in GitHub Desktop.
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
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