Skip to content

Instantly share code, notes, and snippets.

@charlenopires
Created September 3, 2018 23:03
Show Gist options
  • Save charlenopires/987fb920d08f533d37fc12b9ed50518a to your computer and use it in GitHub Desktop.
Save charlenopires/987fb920d08f533d37fc12b9ed50518a to your computer and use it in GitHub Desktop.
Desafio em Dart para um Meetup
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="scaffolded-by" content="https://github.com/google/stagehand">
<title>bolo</title>
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="favicon.ico">
<script defer src="main.dart.js"></script>
</head>
<body>
</body>
</html>
import 'dart:html';
/*
1) Deseja criar o bolo? Nâo => Obrigado!
2) Escolha o sabor: Chocolate Cenoura ...
3) Qual o tamanho? P M G GG
*/
void main() {
String sabor = "";
String tamanho = "";
ButtonElement sim = ButtonElement()..text = "Sim";
ButtonElement nao = ButtonElement()..text = "Não";
DivElement painel = DivElement()
..text = "Deseja criar o bolo?"
..append(sim)
..append(nao);
document.body.nodes.add(painel);
sim.onClick.listen((Event e){
ButtonElement choco = ButtonElement()
..text = "Chocolate"
..value = "Chocolate"
..className = "btn";
ButtonElement mora = ButtonElement()
..text = "Morango"
..value = "Morango"
..className = "btn";
ButtonElement bauni = ButtonElement()
..text = "Baunilha"
..value = "Baunilha"
..className = "btn";
ButtonElement leite = ButtonElement()
..text = "Leite"
..value = "Leite"
..className = "btn";
painel
..text = "Escolha o sabor:"
..append(choco)
..append(mora)
..append(bauni)
..append(leite);
for(ButtonElement btn in querySelectorAll(".btn")){
btn.onClick.listen((Event e){
ButtonElement p = ButtonElement()
..text = "P"
..value = "P"
..className = "tam";
ButtonElement m = ButtonElement()
..text = "M"
..value = "M"
..className = "tam";
ButtonElement g = ButtonElement()
..text = "G"
..value = "G"
..className = "tam";
ButtonElement gg = ButtonElement()
..text = "GG"
..value = "GG"
..className = "tam";
painel
..text = "Qual o tamanho?"
..append(p)
..append(m)
..append(g)
..append(gg);
for(ButtonElement tam in querySelectorAll(".tam")){
tam.onClick.listen((MouseEvent e){
painel.text = "Você escolheu um Bolo de sabor: ${btn.value} e de tamanho: ${tam.value}";
});
}
});
}
});
nao.onClick.listen((Event e) => painel.text = "Agradecemos sua visita!!!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment