fromString static method
Implementation
static FunctionParamType fromString(String name) {
if (name.endsWith(']')) {
final lastOpeningsBracket = name.lastIndexOf('[');
final length = (name.length - 1) - lastOpeningsBracket > 1
? int.parse(name[lastOpeningsBracket + 1])
: 0;
final itemTypeName = name.substring(0, lastOpeningsBracket);
final itemParamType = fromString(itemTypeName);
return itemParamType.getArrayType(length);
}
if (name.startsWith('(') && name.endsWith(')')) {
final nameWithoutParentheses = name.substring(1, name.length - 1);
final tupleTypes = extractParams(nameWithoutParentheses)
.map((e) => fromString(e.$1))
.toList();
return TupleFunctionParamType(name, tupleTypes);
}
return _elementaryTypes.singleWhere(
(element) => element.name == name,
orElse: () => throw Exception('Invalid type: $name'),
);
}