listType(example) {
var x = example.runtimeType;
if (x == List) {
return true;
} else {
return false;
}
}
print(listType([1, 2, 3, 4]));
You can swap swap x==List with x==List< int> and see the difference!!!
How do i make it so that runtimeType always returns true as long as the return type is a list?
>Solution :
If you want to check the type use is and do not use runtimeType because it make x a type not list<int>, like this:
listType(example) {
if (example is List) { //<--- here
return true;
} else {
return false;
}
}