toArray method

Map<String, dynamic> toArray()

Implementation

Map<String, dynamic> toArray() {
  Map<String, dynamic> result = {};

  List<Relation> relations = getRelations();

  _data.forEach((key, value) {
    for (Relation relation in relations) {
      if (relation.id == key) {
        continue;
      }
    }

    if (value is Enum) {
      result[key] = value.name;
    } else if (value is Model) {
      /**
       * Do not save model data in other model datas cache.
       */
    } else if (value is List<Model>) {
      /**
       * Do not save model data in other model datas cache.
       */
    } else {
      result[key] = value;
    }
  });

  onArray().forEach((key, value) {
    result[key] = value;
  });

  return result;
}