Skip to content

Instantly share code, notes, and snippets.

@lukas-h
Last active July 16, 2018 18:24
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 lukas-h/68877d87910d56367a691ad7a43a6b01 to your computer and use it in GitHub Desktop.
Save lukas-h/68877d87910d56367a691ad7a43a6b01 to your computer and use it in GitHub Desktop.
Dart Model View Control Test
import 'dart:html';
import 'dart:math';
class View{
var button, text, listener;
View(Function f){
button = querySelector("#button");
text = querySelector("#text");
listener = button.onClick.listen(f);
}
setText(String s){
text.innerHtml = s;
}
}
class Model{
final array = [
"Hallo",
"Hi",
"Grüß Gott"
];
getRandomData(){
return array[new Random().nextInt(array.length)];
}
}
class Controller{
var view, model;
Controller(){
model = new Model();
view = new View((e){
view.setText(model.getRandomData());
});
}
}
main() => new Controller();
<button id="button">Drücken!</button>
<span id="text"></>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment