In dart consider the following
class Question<T>{
String body;
T answer;
}
//an interface
class IAnswer{
String Value()=>this.toString();
}
I need T to be limited to types the for example implement the interface IAnswer, is that possible without having to check if T is IAnswer and throw and exception in the Question constructor?
class Question<T extends IAnswer>{
String body;
T answer;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With