update method
Partially updates an existing entry in the store.
Updates the entry under key
. This is a partial update that will only
change the fields specified in updateFields
, all other fields of the
entry stay unchanged. To delete a field, add it with null
to
updateFields
.
By default, always returns null
. However, if you specify currentData
,
if the request succeeds, the currentData
will be patched with
updateFields
and the patched entry returned, mirroring the current state
on the server, given that currentData
is the same as the previous server
state.
Implementation
Future<T?> update(
String key,
Map<String, dynamic> updateFields, {
T? currentData,
}) async {
final response = await restApi.patch(
updateFields,
path: _buildPath(key),
printMode: currentData == null ? PrintMode.silent : null,
);
return currentData != null
? patchData(currentData, response.data as Map<String, dynamic>)
: null;
}