Skip to content

Instantly share code, notes, and snippets.

@dpossas
Created July 21, 2020 11:54
Show Gist options
  • Save dpossas/3f798d005a77d38355c6c01201b55c54 to your computer and use it in GitHub Desktop.
Save dpossas/3f798d005a77d38355c6c01201b55c54 to your computer and use it in GitHub Desktop.
Dart - The basics in pratice
class ShoppingCart {
List<Product> _products = [];
List<Product> get products => this._products;
void addItem(Product product){
this.products.add(product);
}
double total() {
double total = 0;
this.products.forEach((Product p) {
total += p.price;
});
return total;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment