iterableCast static method
Cast mapped values to their desired output value
Implementation
static String iterableCast(
DartType argType, {
bool isSet = false,
bool isList = false,
bool isFuture = false,
bool forceCast = false,
}) {
final nullableSuffix = argType.nullabilitySuffix != NullabilitySuffix.none ? '?' : '';
var castStatement = nullableSuffix;
if (isSet || isList) {
final method = isSet ? 'Set' : 'List';
castStatement += '.to$method()';
}
if (forceCast) {
final castType = isFuture ? 'Future<$argType>' : argType;
castStatement += '.cast<$castType>()';
}
return castStatement;
}