I need to determine if a generic type is a String, bool, int, double or another class at runtime. I didn't found a way to do it for nullable types:
class Foo<T> {
void foo() {
if (T == int) {
print("'T' is an int");
} else {
print("'T' is not an int");
}
}
}
void main() {
final foo = Foo<int>();
final bar = Foo<int?>();
foo.foo();
bar.foo();
}
console output:
// 'T' is an int
// 'T' is not an int
Is there any syntax I'm unaware of to check for the nullable type?, I've already tried with int? but it doesn't compile.