Skip to content

Instantly share code, notes, and snippets.

@esaesa
Last active October 31, 2020 10:43
Show Gist options
  • Save esaesa/473b8953eff9cd8272180ae504b8798c to your computer and use it in GitHub Desktop.
Save esaesa/473b8953eff9cd8272180ae504b8798c to your computer and use it in GitHub Desktop.
void main() {
Product p1 = Product(id: 1, name:"test1" , price: 100);
Product p3 = Product(id: 1, name:"test1" , price: 100);
Product p2 = Product(id: 1, name:"test2", price: 200);
List<Product> products= new List();
products.add(p1);
products.add(p3);
Map<Product,int> cart = {};
cart[p1] = 10;
cart[p2] = 20;
cart.forEach((key,item){
key.printMe();
print("Value is $item");
});
print(cart.containsKey(p1));
print(cart.containsKey(products[0]));
print(cart.containsKey(p3));
}
class Product{
final name;
final id;
final price;
Product({this.id,this.name, this.price});
printMe(){
print("I am $name");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment