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(){ | |
Cachorro doge = Cachorro('Doge'); | |
print(doge.nome); | |
doge.latir(); | |
Gato gato = Gato('Paulo'); | |
print(gato.nome); | |
gato.miar(); |
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
// 1. Sem static: consultamos através da instância da classe | |
// 2. Com static: consultamos diretamente pela classe | |
void main() { | |
// 1. | |
var pessoa1 = Pessoa1(); | |
print(pessoa1.escola); | |
print(pessoa1.estudar()); |
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() { | |
var pessoa = Pessoa(); | |
pessoa.altura = 1.85; // ok | |
pessoa.altura = 5.00; // > 2.5 → 'Altura inválida' | |
} | |
class Pessoa { | |
double? _altura; | |
double? get altura => _altura; |
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() { | |
var pessoa = Pessoa(); | |
print(pessoa._altura); | |
} | |
class Pessoa { | |
double _altura = 1.85; | |
} |
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
// Tipos de Construtores: | |
// 1. `Pessoa()`: construtor padrão (default constructor). | |
// Uso → `pessoa.nome` | `pessoa.idade`. | |
// 2. `Pessoa2(this.nome, this.idade)`: construtor parametrizado (parameterized constructor). | |
// Uso → `Pessoa('Felipe', 17)`. | |
// 3. `Pessoa({required this.nome, required this.idade})`: construtor nomeado (named constructor). | |
// Uso → `Pessoa(nome: 'Felipe', idade: 17)`. | |
void main() { |
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() { | |
var pessoa = Pessoa(); | |
print(pessoa.nome); // 'Felipe' | |
pessoa.estudar(); // 'Felipe está estudando POO' | |
} | |
class Pessoa { | |
String nome = 'Felipe'; | |
void estudar(){ | |
print('$nome está estudando POO'); |
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() { | |
var pessoa = Pessoa(); | |
print(pessoa.nome); // 'Felipe' | |
} | |
class Pessoa { | |
String nome = 'Felipe'; | |
} |
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() { | |
var pessoa = Pessoa(); | |
print(pessoa); | |
} | |
class Pessoa { | |
} |
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
////////////////////////////////////////////////////////////////// | |
// // | |
// +----------------------------------------------------+ // | |
// | | Obrigatórios | Opcionais | // | |
// +-------------+----------------------+---------------+ // | |
// | Posicionais | func(int a) | func([int a]) | // | |
// +-------------+----------------------+---------------+ // | |
// | Nomeados | func(required int a) | func({int a}) | // | |
// +----------------------------------------------------+ // |
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
////////////////////////////////////////////////////////////////// | |
// // | |
// +----------------------------------------------------+ // | |
// | | Obrigatórios | Opcionais | // | |
// +-------------+----------------------+---------------+ // | |
// | Posicionais | func(int a) | func([int a]) | // | |
// +-------------+----------------------+---------------+ // | |
// | Nomeados | func(required int a) | func({int a}) | // | |
// +----------------------------------------------------+ // |