autoParse function
Converts the desired fields to their numeric representations, if present.
Implementation
Map<String, dynamic> autoParse(Map inputData, Iterable<String> fields) {
var data = <String, dynamic>{};
for (var key in inputData.keys) {
if (!fields.contains(key)) {
data[key.toString()] = inputData[key];
} else {
try {
var n = inputData[key] is num
? inputData[key]
: num.parse(inputData[key].toString());
data[key.toString()] = n == n.toInt() ? n.toInt() : n;
} catch (e) {
// Invalid number, don't pass it
}
}
}
return data;
}