toMap method

Map<String, dynamic> toMap({
  1. bool forModelJson = false,
})

See ModelEntity.toMap for important details.

Note that the order in which keys are written defines the order in the generated model JSON.

Implementation

Map<String, dynamic> toMap({bool forModelJson = false}) {
  final ret = <String, dynamic>{};
  ret[ModelRelationKey.id] = id.toString();
  ret[ModelRelationKey.name] = name;
  if (externalName != null) ret[ModelRelationKey.externalName] = externalName;
  if (externalType != null) ret[ModelRelationKey.externalType] = externalType;
  if (_targetId != null) {
    ret[ModelRelationKey.targetId] = _targetId.toString();
  }
  if (!forModelJson) {
    ret[ModelRelationKey.targetName] = _targetName;
    ret[ModelRelationKey.uidRequest] = uidRequest;
  }
  return ret;
}