@@ -86,7 +86,8 @@ class ParseObject extends ParseBase implements ParseCloneable {
8686 /// Creates a new object and saves it online
8787 ///
8888 /// Prefer using [save] over [create]
89- Future <ParseResponse > create ({bool allowCustomObjectId = false }) async {
89+ Future <ParseResponse > create (
90+ {bool allowCustomObjectId = false , dynamic context}) async {
9091 try {
9192 final Uri url = getSanitisedUri (_client, _path);
9293 final String body = json.encode (toJson (
@@ -96,8 +97,17 @@ class ParseObject extends ParseBase implements ParseCloneable {
9697
9798 _saveChanges ();
9899
99- final ParseNetworkResponse result =
100- await _client.post (url.toString (), data: body);
100+ final Map <String , String > headers = {
101+ keyHeaderContentType: keyHeaderContentTypeJson,
102+ };
103+
104+ if (context != null ) {
105+ headers
106+ .addAll ({keyHeaderCloudContext: json.encode (parseEncode (context))});
107+ }
108+
109+ final ParseNetworkResponse result = await _client.post (url.toString (),
110+ data: body, options: ParseNetworkOptions (headers: headers));
101111
102112 final response = handleResponse <ParseObject >(
103113 this , result, ParseApiRQ .create, _debug, parseClassName);
@@ -120,7 +130,7 @@ class ParseObject extends ParseBase implements ParseCloneable {
120130 /// The object should hold an [objectId] in order to update it
121131 ///
122132 /// Prefer using [save] over [update]
123- Future <ParseResponse > update () async {
133+ Future <ParseResponse > update ({ dynamic context} ) async {
124134 assert (
125135 objectId != null && (objectId? .isNotEmpty ?? false ),
126136 "Can't update a parse object while the objectId property is null or empty" ,
@@ -133,9 +143,14 @@ class ParseObject extends ParseBase implements ParseCloneable {
133143 _saveChanges ();
134144
135145 final Map <String , String > headers = {
136- keyHeaderContentType: keyHeaderContentTypeJson
146+ keyHeaderContentType: keyHeaderContentTypeJson,
137147 };
138148
149+ if (context != null ) {
150+ headers
151+ .addAll ({keyHeaderCloudContext: json.encode (parseEncode (context))});
152+ }
153+
139154 final ParseNetworkResponse result = await _client.put (url.toString (),
140155 data: body, options: ParseNetworkOptions (headers: headers));
141156
@@ -185,14 +200,14 @@ class ParseObject extends ParseBase implements ParseCloneable {
185200 /// Its safe to call this function aging if an error occurred while saving.
186201 ///
187202 /// Prefer using [save] over [update] and [create]
188- Future <ParseResponse > save () async {
203+ Future <ParseResponse > save ({ dynamic context} ) async {
189204 final ParseResponse childrenResponse = await _saveChildren (this );
190205 if (childrenResponse.success) {
191206 ParseResponse ? response;
192207 if (objectId == null ) {
193- response = await create ();
208+ response = await create (context : context );
194209 } else if (_isDirty (false )) {
195- response = await update ();
210+ response = await update (context : context );
196211 }
197212
198213 if (response != null ) {
0 commit comments