convertValueByKind method
dynamic
convertValueByKind(
- String kind,
- dynamic value
)
Implementation
dynamic convertValueByKind(String kind, dynamic value) {
if (value is String) {
switch (kind) {
case 'boolean':
return value.toLowerCase() == 'true';
case 'string':
// Value is already a string, so we just return it
return value;
case "int":
// Number flags can be integer or floating point
final intValue = int.tryParse(value);
if (intValue != null) {
return intValue;
}
final doubleValue = double.tryParse(value);
if (doubleValue != null) {
return doubleValue;
}
break;
case 'json':
return _iterativeJsonDecode(value);
}
}
// Return the original value if it's not a string or if the kind is not recognized
return value;
}