Order class
Represents an order containing multiple items and the associated costs.
The Order class contains a list of Item objects, the subtotal for the items, applicable tax, and the final total cost.
Example:
Order order = Order(
invoiceNumber: vh524245426
paymentMethod: CASH
items: [
Item(name: 'Pizza', quantity: 1, price: 10.0, category: 'Food')
],
subtotal: 10.0,
tax: 1.5,
total: 11.5
);
Constructors
-
Order({required String date, required String invoiceNumber, required String paymentMethod, required List<
Item> items, required double subtotal, required double tax, required double total}) -
Creates a new Order object with the given
items
,subtotal
,tax
, andtotal
. -
Order.fromJson(Map<
String, dynamic> json) -
Converts a JSON object into an Order object.
factory
Properties
- date ↔ String
-
The date of the transaction
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- invoiceNumber ↔ String
-
invoice number, this is the unique number of the transaction
getter/setter pair
-
items
↔ List<
Item> -
The list of items in the order.
getter/setter pair
- paymentMethod ↔ String
-
This is the method used to make the transaction and always in upper case
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- subtotal ↔ double
-
The subtotal amount before tax.
getter/setter pair
- tax ↔ double
-
The amount of tax applied to the order.
getter/setter pair
- total ↔ double
-
The final total amount after tax.
getter/setter pair
Methods
-
copyWith(
{List< Item> ? items, double? subtotal, double? tax, double? total, String? invoiceNumber, String? date, String? paymentMethod}) → Order - Returns a copy of this Order object with the given fields replaced by new values.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Converts this Order object into a JSON object.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited