copyWith method

MotherDetailsState copyWith({
  1. List<Document>? allMothers,
  2. List<Document>? filteredMothers,
  3. DateTime? fromDate,
  4. bool clearFromDate = false,
  5. DateTime? tillDate,
  6. bool clearTillDate = false,
  7. String? searchQuery,
  8. bool? isLoading,
  9. String? errorMessage,
  10. bool clearError = false,
})

Returns a copy of this state with updated fields if provided.

Implementation

MotherDetailsState copyWith({
  List<models.Document>? allMothers,
  List<models.Document>? filteredMothers,
  DateTime? fromDate,
  bool clearFromDate = false,
  DateTime? tillDate,
  bool clearTillDate = false,
  String? searchQuery,
  bool? isLoading,
  String? errorMessage,
  bool clearError = false,
}) {
  return MotherDetailsState(
    allMothers: allMothers ?? this.allMothers,
    filteredMothers: filteredMothers ?? this.filteredMothers,
    fromDate: clearFromDate ? null : (fromDate ?? this.fromDate),
    tillDate: clearTillDate ? null : (tillDate ?? this.tillDate),
    searchQuery: searchQuery ?? this.searchQuery,
    isLoading: isLoading ?? this.isLoading,
    errorMessage: clearError ? null : (errorMessage ?? this.errorMessage),
  );
}