viewHash static method

String viewHash(
  1. ChartDocument document,
  2. ChartViewState? viewState
)

Hashes the document together with the durable view state that should be restored by a hydrator.

A missing view state is encoded explicitly so this identity cannot be confused with a document-only hash.

Implementation

static String viewHash(ChartDocument document, ChartViewState? viewState) =>
    _sha256(
      canonicalJsonEncode({
        'document': document.toJson(),
        'viewState': viewState?.toJson(),
      }),
    );