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
class Pessoa { | |
String nome; | |
int idade; | |
double dinheiro; | |
Pessoa(this.nome, this.idade, this.dinheiro); | |
@override | |
String toString(){ | |
return "$nome,\t$idade,\t R\$ $dinheiro"; |
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
class Pessoa { | |
String nome; | |
int idade; | |
Pessoa(this.nome, this.idade); | |
@override | |
String toString(){ | |
return "$nome,\t$idade"; | |
} |
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() { | |
// códigos anteriores aqui | |
pessoas.sort((a, b) { | |
// Primeiro, comparar pelo campo nome | |
int comparacao = -a.nome.compareTo(b.nome); | |
if (comparacao != 0) { | |
return comparacao; | |
} | |
// Se os nomes forem iguais, comparar pelo campo idade |
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() { | |
//código anteriores aqui | |
pessoas.sort((a, b) { | |
// Primeiro, comparar pelo campo nome | |
int comparacao = a.nome.compareTo(b.nome); | |
if (comparacao != 0) { | |
return comparacao; | |
} | |
// Se os nomes forem iguais, comparar pelo campo idade |
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(){ | |
// códigos que inicia a lsita de pessoas aqui | |
pessoas.sort((a, b) { | |
// Primeiro, comparar pelo campo nome | |
int comparacao = a.nome.compareTo(b.nome); | |
if (comparacao != 0) { | |
return comparacao; | |
} | |
// Se os nomes forem iguais, comparar pelo campo idade | |
return a.idade.compareTo(b.idade); |
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() { | |
List<int> numeros = [0, 5, 2, 4, 7, 1, 9, 6, 3, 8]; | |
print(numeros); | |
// [0, 5, 2, 4, 7, 1, 9, 6, 3, 8] | |
//ASC - ascendente | |
numeros.sort(); | |
print(numeros); | |
// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
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() { | |
List<Pessoa> pessoas = [ | |
Pessoa('Maria', 34), | |
Pessoa('João', 25), | |
Pessoa('Pedro', 23), | |
Pessoa('João', 18), | |
Pessoa('João', 17), | |
Pessoa('Lucas', 15), | |
Pessoa('Maria', 37), | |
Pessoa('Maria', 18), |
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
class Pessoa { | |
String nome; | |
int idade; | |
Pessoa(this.nome, this.idade); | |
@override | |
String toString(){ | |
return "$nome,\t$idade"; | |
} |
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() { | |
//i++ | |
//i += 1 | |
//i = i + 1 | |
for (int i = 0; i < 5; i = i + 2) { | |
print('hello $i'); | |
} | |
List numeros = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; |
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() { | |
// variáveis podem ser modificadas | |
// String nome = "Ana Beatriz"; | |
// modificador de proteção variável (final, const) | |
// const String nome = "Ana Beatriz"; | |
// const nome = "Ana Beatriz"; | |
final String nome = "Ana Beatriz"; | |
print(nome); |