beforeDeserialize method

  1. @override
Object? beforeDeserialize(
  1. Object? object,
  2. FullType specifiedType
)
override

Implementation

@override
Object? beforeDeserialize(Object? object, FullType specifiedType) {
  if (applyOnTypes != null) {
    if (!applyOnTypes!.contains(specifiedType.root)) {
      return object;
    }
  }
  try {
    if (object is List) {
      /// let see if is an intended key value dictionary
      /// by checking if its keys equal to half its size
      /// if they dont match most likely this is a flat array
      final map = pairedListToMap(object);
      if (map.length != object.length / 2) {
        return object;
      }
      return modifyPairedListAsMap(object, (value) {
        if (value["_id"] != null && value["id"] == null) {
          value["id"] = value["_id"];
        }
        return value;
      });
    }
    return object;
    //           result.profilePictureUrl = (value as Map<String, dynamic>)["profilePicture"]?["url"];
  } catch (e) {
    return object;
  }
}