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
{ | |
"aaaTest": {// criar estrutura de testes "triple a" (arrange, act, assert) | |
"prefix": "aaa", | |
"body": [ | |
"test(", | |
"\t'should $1',", | |
"\t() async {", | |
"\t\t// arrange", | |
"\t\t$2", | |
"\t\t// act", |
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 d1 = DateTime(2021, 2, 4); | |
var d2 = DateTime.now(); | |
print(d2.difference(d1).inDays); | |
} |
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
// menu > opções > Página inicial e novas janelas > URLs personalizadas > Copiar o conteúdo do campo (caso exista) | |
void main() { | |
String fromFirefox = '<from-firefox>'; | |
String token = '|'; | |
List<String> urls = fromFirefox.split(token); | |
urls.add('<new-url>'); | |
urls.insert(<at-position>, '<new-url>'); | |
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
import 'package:flutter/material.dart'; | |
final pc = Colors.blueGrey.shade900; | |
final sc = Colors.blueGrey.shade800; | |
final bc = Colors.blueGrey; | |
final wc = Colors.white; | |
final ac = Colors.amber; | |
final tc = Colors.transparent; | |
final gc = Colors.green; | |
final rc = Colors.red; |
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() { | |
Contador single = Contador(); | |
Contador single2 = Contador(); | |
Contador single3 = Contador(); | |
print(single.count++); | |
print(single2.count++); | |
print(single3.count); | |
} |
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() { | |
Venda venda = Venda(); | |
CalculadoraDesconto calculadora = CalculadoraDesconto(); | |
venda.adicionarItem(Item('Tenis', 270.0)); | |
venda.adicionarItem(Item('Sapato', 350.0)); | |
venda.adicionarItem(Item('Camisa', 200.0)); | |
venda.adicionarItem(Item('Calça', 180.0)); | |
double desconto = calculadora.calcularDesconto(venda); |
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() { | |
Imposto icms = ICMS(); | |
Imposto iptu = IPTU(); | |
CalculoImposto calc = CalculoImposto(); | |
print(calc.calcularImposto(icms, 100)); | |
print(calc.calcularImposto(iptu, 50)); | |
} |
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() { | |
// criando variável teste. | |
String teste = 'teste'; | |
// "printa" 5 no console. | |
print(teste.length); | |
// setando valor para null. | |
teste = null; | |
// caso tente acessar a variável diretamente esta estando nula, uma exceção é lançada. | |
// com o operador ?. isso é evitado pois a variável teste somente é acessada quando seu valor for diferente de nulo. | |
print(teste?.length); |
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
extension on String { | |
String concat(String toConcat) => this + toConcat; | |
} | |
main() { | |
String test = 'primeira'; | |
String expected = test.concat(' e segunda'); | |
assert('primeira e segunda' == expected); | |
print(expected); |
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
public <T> T clone(Object obj, Class<T> clazz) throws Exception { | |
ObjectMapper objectMapper = new ObjectMapper(); | |
try { | |
return objectMapper.readValue(objectMapper.writeValueAsString(obj), clazz); | |
} catch (IOException e) { | |
throw new Exception(); | |
} | |
} |
NewerOlder