copyWith method

WsDbState<T> copyWith({
  1. bool? loading,
  2. String? docId,
  3. Object? doc = _u,
  4. Object? error = _u,
  5. bool? isWatching,
})

Returns a new state with overridden fields.

Implementation

WsDbState<T> copyWith({
  bool? loading,
  String? docId,
  Object? doc = _u, // <— usa Object para sentinel
  Object? error = _u,
  bool? isWatching,
}) {
  return WsDbState<T>(
    loading: loading ?? this.loading,
    docId: docId ?? this.docId,
    isWatching: isWatching ?? this.isWatching,
    doc: doc == _u ? this.doc : doc as T?,
    error: error == _u ? this.error : error as ErrorItem?,
  );
}