convertStringToObject static method

dynamic convertStringToObject(
  1. dynamic text
)

Converts a string to an object

@param text The text to convert @return The converted object or the original text if conversion fails

Implementation

static dynamic convertStringToObject(dynamic text) {
  try {
    if (isNullOrEmpty(text)) return null;
    if (text is String) {
      return jsonDecode(text);
    }
  } catch (ex, s) {
    Completer().completeError(ex, s);
  }
  return text;
}