convertFromJson<ResultType, Item> method

ResultType? convertFromJson<ResultType, Item>(
  1. dynamic data, [
  2. String? key
])

convert a json string to a builtvalue with type ResultType

Implementation

ResultType? convertFromJson<ResultType, Item>(dynamic data, [String? key]) {
  try {
    if (data is String) data = json.decode(data);
    if (data is String) data = json.decode(data);
  } catch (e) {
    if (kDebugMode) {
      print(
          'in convert fromjson error $e, $key, ${data?.runtimeType}, $data');
    }
  }
  try {
    return _decode<Item>(_getBody(data, key));
  } catch (e, _) {
    if (kDebugMode) {
      print(e);
      print(_);
    }
    return null;
  }
}