I have a function with a return type of List<T?>?
. I know that I can use the !
operator to convert this return type to List<T?>
, but how do I then convert this to a List<T>
?
Code that I've tried:
// testFunction returns List<T?>?
var test = testFunction() as List<T>? ?? [];
Result:
The following _CastError was thrown building ...:
type 'List<T?>' is not a subtype of type 'List<T>?' in type cast