objectToSerializable function

Object objectToSerializable (dynamic object, { dynamic depth, dynamic exclude, String fieldName })

Converts the object to a serializable Map, String, int, DateTime or any other serializiable object.

Parameters:

  • depth : determines how deep is going to be the serialization and to avoid cyclical object reference stack overflow.
  • exclude : exclude some attributes. It could be String, Map, or List

Implementation

Object objectToSerializable(object, {depth, exclude, String fieldName}) {
  if (isPrimitive(object)) {
//    _serLog.fine("Found primetive: $object");
    return object;
  } else if (object is DateTime) {
//    _serLog.fine("Found DateTime: $object");
    return object.toIso8601String();
  } else if (object is List) {
//    _serLog.fine("Found list: $object");
    return _serializeList(object, depth, exclude, fieldName);
  } else if (object is! SerializableMap && object is Map) {
//    _serLog.fine("Found map: $object");
    return _serializeMap(object, depth, exclude, fieldName);
  } else if (object is Set) {
//    _serLog.fine("Found set: $object");
    return _serializeSet(object, depth, exclude, fieldName);
  } else {
//    _serLog.fine("Found object: $object");
    return _serializeObject(object, depth, exclude, fieldName);
  }
}