parseValue function

dynamic parseValue(
  1. String rawValue
)

Implementation

dynamic parseValue(String rawValue) {
  // Handle numeric values
  if (RegExp(r'^\d+$').hasMatch(rawValue)) {
    return int.parse(rawValue);
  }
  if (RegExp(r'^\d*\.\d+$').hasMatch(rawValue)) {
    return double.parse(rawValue);
  }

  // Handle boolean values
  if (rawValue.toLowerCase() == 'true') return true;
  if (rawValue.toLowerCase() == 'false') return false;

  // Handle quoted strings by removing quotes and proper escaping
  if (rawValue.startsWith('"') && rawValue.endsWith('"')) {
    return rawValue.substring(1, rawValue.length - 1).replaceAll(r'\"', '"');
  }
  if (rawValue.startsWith("'") && rawValue.endsWith("'")) {
    return rawValue.substring(1, rawValue.length - 1).replaceAll(r"\'", "'");
  }

  // Return as is for other cases
  return rawValue;
}