create method

Future<String> create(
  1. T data, {
  2. ETagReceiver? eTagReceiver,
})

Creates a new entry in the store.

This method will store data under a random, server generated key in the store, ensuring it is always a new child and will not replace anything. On success, the key of the newly created entry is returned.

If eTagReceiver was specified, it will contain the current eTag of the created entry after the returned future was resolved.

Implementation

Future<String> create(T data, {ETagReceiver? eTagReceiver}) async {
  final response = await restApi.post(
    dataToJson(data),
    path: _buildPath(),
    eTag: eTagReceiver != null,
  );
  _applyETag(eTagReceiver, response);
  final result = PostResponse.fromJson(response.data as Map<String, dynamic>);
  return result.name;
}