copyWith method

Order copyWith({
  1. List<Item>? items,
  2. double? subtotal,
  3. double? tax,
  4. double? total,
})

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,
}) {
  return Order(
    items: items ?? this.items,
    subtotal: subtotal ?? this.subtotal,
    tax: tax ?? this.tax,
    total: total ?? this.total,
  );
}