copyWith method

SwayzeHeaderState copyWith({
  1. int? count,
  2. int? elasticCount,
  3. Iterable<SwayzeHeaderData>? headerData,
  4. int? frozenCount,
})

Copies the state overriding specific fields.

If headerData is not provided, reuse the current map of customSizedHeaders.

Implementation

SwayzeHeaderState copyWith({
  int? count,
  int? elasticCount,
  Iterable<SwayzeHeaderData>? headerData,
  int? frozenCount,
}) {
  if (headerData != null) {
    return SwayzeHeaderState(
      elasticCount: elasticCount ?? this.elasticCount,
      defaultHeaderExtent: defaultHeaderExtent,
      count: count ?? this.count,
      headerData: headerData,
      frozenCount: frozenCount ?? this.frozenCount,
    );
  }

  return SwayzeHeaderState._fromSortedHeaderData(
    elasticCount: elasticCount ?? this.elasticCount,
    defaultHeaderExtent: defaultHeaderExtent,
    count: count ?? this.count,
    sortedHeaderData: _customSizedHeaders,
    frozenCount: frozenCount ?? this.frozenCount,
  );
}