create method
Creates a new object and saves it online
Prefer using save over create
Implementation
Future<ParseResponse> create({
bool allowCustomObjectId = false,
dynamic context,
}) async {
try {
final Uri url = getSanitisedUri(_client, _path);
final String body = json.encode(
toJson(forApiRQ: true, allowCustomObjectId: allowCustomObjectId),
);
_saveChanges();
final Map<String, String> headers = {
keyHeaderContentType: keyHeaderContentTypeJson,
};
if (context != null) {
headers.addAll({
keyHeaderCloudContext: json.encode(parseEncode(context)),
});
}
final ParseNetworkResponse result = await _client.post(
url.toString(),
data: body,
options: ParseNetworkOptions(headers: headers),
);
final response = handleResponse<ParseObject>(
this,
result,
ParseApiRQ.create,
_debug,
parseClassName,
);
if (!response.success) {
_notifyChildrenAboutErrorSaving();
}
return response;
} on Exception catch (e) {
_notifyChildrenAboutErrorSaving();
return handleException(e, ParseApiRQ.create, _debug, parseClassName);
}
}