Skip to content

Instantly share code, notes, and snippets.

@TetsuFe
Created July 11, 2020 05:53
Show Gist options
  • Save TetsuFe/fbe6c91694a8c28387fa9fe02fece45f to your computer and use it in GitHub Desktop.
Save TetsuFe/fbe6c91694a8c28387fa9fe02fece45f to your computer and use it in GitHub Desktop.
class Item {
Item(price) {
this.price = price;
}
int price;
}
class Cart {
final items = [Item(1), Item(2)];
int get totalPrice => items.fold(0, (cur, item) => cur + item.price);
}
void main() {
print(Cart().totalPrice);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment