Skip to content

Instantly share code, notes, and snippets.

@mannuelf
Created July 18, 2022 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mannuelf/08d9b22b531db6cbb403be2f862de69f to your computer and use it in GitHub Desktop.
Save mannuelf/08d9b22b531db6cbb403be2f862de69f to your computer and use it in GitHub Desktop.
dom-select-streams
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dom-select-streams</title>
<link rel="stylesheet" href="styles.css">
<script type="application/dart" src="main.dart"></script>
</head>
<body>
<h1>Guess the word</h1>
<input id="guesses"/>
<button id="myButton">Click me</button>
</body>
</html>
import 'dart:html';
void main() {
final button = querySelector('button') as ButtonElement;
final input = querySelector('input') as InputElement;
button.onClick
.take(4)
.where((event) => input.value == 'magic')
.listen(
(event) => print('you got it!'),
onDone: () => print('Noope, bad guesses.')
);
}
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: absolute;
width: 100%;
height: 100%;
}
h1 {
color: white;
font-family: Arial, Helvetica, sans-serif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment