copyWith method

Order copyWith({
  1. List<Item>? items,
  2. double? subtotal,
  3. double? tax,
  4. double? total,
  5. String? invoiceNumber,
  6. String? date,
  7. String? paymentMethod,
})

Returns a copy of this Order object with the given fields replaced by new values.

This can be useful when you want to create a modified version of an existing order without changing the original object.

Implementation

Order copyWith({
  List<Item>? items,
  double? subtotal,
  double? tax,
  double? total,
  String? invoiceNumber,
  String? date,
  String? paymentMethod,
}) {
  return Order(
    date: date ?? this.date,
    invoiceNumber: invoiceNumber ?? this.invoiceNumber,
    paymentMethod: paymentMethod ?? this.paymentMethod,
    items: items ?? this.items,
    subtotal: subtotal ?? this.subtotal,
    tax: tax ?? this.tax,
    total: total ?? this.total,
  );
}