writeFragment<TData, TVars> method Null safety

void writeFragment<TData, TVars>(
  1. FragmentRequest<TData, TVars> request,
  2. TData data,
  3. {OperationRequest? optimisticRequest}

Normalizes data for the given fragment and writes it to the Store.

If an optimisticRequest is provided, the changes will be written as an optimistic patch and will be reverted once a non-optimistic response is received for the optimisticRequest.


void writeFragment<TData, TVars>(
  FragmentRequest<TData, TVars> request,
  TData data, {
  OperationRequest? optimisticRequest,
}) {
    read: optimisticRequest != null
        ? optimisticReader
        : (dataId) => store.get(dataId),
    write: (dataId, value) => _writeData(
    document: request.document,
    idFields: request.idFields,
    fragmentName: request.fragmentName,
    // TODO: don't cast to dynamic
    variables: (request.vars as dynamic)?.toJson(),
    data: (data as dynamic)?.toJson(),
    typePolicies: typePolicies,
    addTypename: addTypename,
    dataIdFromObject: dataIdFromObject,
    possibleTypes: possibleTypes,