Skip to content

Instantly share code, notes, and snippets.

@timmaffett
Last active March 16, 2022 11:15
Show Gist options
  • Save timmaffett/91d894c115314fbe2fb32e4adb91d17f to your computer and use it in GitHub Desktop.
Save timmaffett/91d894c115314fbe2fb32e4adb91d17f to your computer and use it in GitHub Desktop.
dartpad example for clear console branch
<h1 id="header"></h1>
<button id="clicker"
class="favorite styled"
type="button">
Click me to make console messages
</button>
<br/><br/><br/><br/>
<h3>Open the Console and click the clear console button
<image class="icon" src="https://timmaffett.github.io/clearconsole/pictures/clear-console.svg" />
in the upper right to clear the console messages that you
are generating when clicking the <span class="styled">button</span> above .
</h3>
import 'dart:html';
void main() {
int clickCount=0;
int extraConsoleMessages=0;
final header = querySelector('#header');
header?.text = "Hello, World!";
final testButton = querySelector('#clicker');
final dartSub = testButton!.onClick.listen((_) {
clickCount++;
print('You have clicked me $clickCount times now');
for(int i=0;i<20;i++) {
extraConsoleMessages++;
print(' extra console message $extraConsoleMessages - try the clear console button!');
}
});
for(int i=0;i<20;i++) {
print(' some init console messages $i - try the clear console button!');
}
}
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;
}
h3 {
width: 200px;
font-family: Arial, Helvetica, sans-serif;
}
.icon {
filter: invert(100%);
width: 32px;
height: 32px;
margin: 0px 20px;
}
.styled {
border: 0;
line-height: 2.5;
padding: 0 20px;
font-size: 1rem;
text-align: center;
color: #fff;
text-shadow: 1px 1px 1px #000;
border-radius: 10px;
background-color: cornflowerblue;
background-image: linear-gradient(to top left,
rgba(0, 0, 0, .2),
rgba(0, 0, 0, .2) 30%,
rgba(0, 0, 0, 0));
box-shadow: inset 2px 2px 3px rgba(255, 255, 255, .6),
inset -2px -2px 3px rgba(0, 0, 0, .6);
}
.styled:hover {
background-color: olivedrab;
transition: background-color 2.5s ease-out;
}
.styled:active {
box-shadow: inset -2px -2px 3px rgba(255, 255, 255, .6),
inset 2px 2px 3px rgba(0, 0, 0, .6);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment