Last active
October 31, 2020 10:43
-
-
Save esaesa/473b8953eff9cd8272180ae504b8798c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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