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(){ | |
Categoria cat1 = Categoria(1); | |
List<Item> itens = [ | |
Item(id: 1, completado: false, obrigatorio: false), | |
Item(id: 2, completado: true, obrigatorio: true), | |
Item(id: 3, completado: true, obrigatorio: true), | |
Item(id: 4, completado: true, obrigatorio: false), | |
Item(id: 5, completado: true, obrigatorio: true), | |
]; | |
cat1.itens = itens; |
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() { | |
Duration duration = Duration(minutes: 1, seconds: 10); | |
int d1 = duration.inMicroseconds; | |
Duration duration2 = Duration(minutes: 2, seconds: 25); | |
int d2 = duration2.inMicroseconds; | |
print('$duration -> $d1'); | |
print('$duration2 -> $d2'); | |
int diff = d2-d1; | |
Duration duration3 = Duration(microseconds: diff); | |
print('$duration3 -> $diff'); |
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 'dart:async'; | |
void main() { | |
List convidados = ['Daniel', 'João', 'Marcos', 'Jessica', 'Natalia']; | |
final controller = StreamController(); | |
final subscription = controller.stream | |
.where((conv) => convidados.contains(conv)) | |
.listen((data) => print(data)); |
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() { | |
double num = 1.5; | |
//double num = 1.0; | |
print((num % 1) == 0 ? num.toInt() : num); | |
} |
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 class RedirectView { | |
private String viewName; | |
public RedirectView(String viewName) { | |
this.viewName = viewName; | |
} | |
@Override | |
public String toString() { | |
return viewName + "?faces-redirect=true"; |
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 extends Serializable> T clone(Serializable obj) { | |
ObjectOutputStream out = null; | |
ObjectInputStream in = null; | |
try (ByteArrayOutputStream bout = new ByteArrayOutputStream()) { | |
out = new ObjectOutputStream(bout); | |
out.writeObject(obj); | |
out.close(); |
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(); | |
} | |
} |
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
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
void main() { | |
Imposto icms = ICMS(); | |
Imposto iptu = IPTU(); | |
CalculoImposto calc = CalculoImposto(); | |
print(calc.calcularImposto(icms, 100)); | |
print(calc.calcularImposto(iptu, 50)); | |
} |
OlderNewer