Created with <3 with dartpad.dev.
Created
September 4, 2023 23:34
-
-
Save chritianegozza/debec16dba1286e892e3b292eac8f53e to your computer and use it in GitHub Desktop.
obsidian-toast-1289
This file contains 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() { | |
Carro carro1 = Carro("HB20"); | |
Carro carro2 = Carro("Gol"); | |
Carro carro3 = Carro("Argo"); | |
//map é um par de chave e valor, igual a json | |
final carrosMap = {"1": carro1,"2": carro2}; | |
carrosMap["3"] = carro3; | |
print("Lista: $carrosMap, lenght: ${carrosMap.length}"); | |
//looping pela "key" do map | |
for(String id in carrosMap.keys){ | |
final carrosTemp = carrosMap[id]; | |
print(">> ${carrosTemp?.modelo}"); | |
} | |
} | |
class Carro{ | |
String modelo; | |
Carro(this.modelo); | |
@override | |
String toString(){ | |
return modelo; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment