encodeType static method
Implementation
static String encodeType(
Map<String, List<TypedDataArgument>> typedDataTypes, String primaryType) {
final args = typedDataTypes[primaryType];
if (args == null || args.length == 0) {
throw ArgumentError('TypedDataUtils: $primaryType type is not defined');
}
final List<String> subTypes = [];
String s = primaryType + '(';
for (int i = 0; i < args.length; i++) {
final arg = args[i];
final arrayArg = arg.type.indexOf('[');
final argType = arrayArg < 0 ? arg.type : arg.type.substring(0, arrayArg);
if (typedDataTypes[argType] != null &&
typedDataTypes[argType]!.length > 0) {
bool set = false;
for (int x = 0; x < subTypes.length; x++) {
if (subTypes[x] == argType) {
set = true;
}
}
if (!set) {
subTypes.add(argType);
}
}
s += arg.type + ' ' + arg.name;
if (i < args.length - 1) {
s += ',';
}
}
s += ')';
subTypes.sort();
for (int i = 0; i < subTypes.length; i++) {
final subEncodeType = encodeType(typedDataTypes, subTypes[i]);
s += subEncodeType;
}
return s;
}