El código de abajo "se ve bien", que compila, pero no se ejecuta, en su defecto, con el mensaje de la consola:¿Cómo importo dart: html & dart: io en la misma clase?
Cannot load Dart script dart:io
Failed to load resource
Si comento hacia fuera del #import('dart:io');
, mal creo, me sale un error de compilación, pero se inicia y no hasta que presiono el botón, obtengo el error de tiempo de ejecución:
Internal error: 'http://127.0.0.1:3030/home/david/dart/samples/htmlIO/htmlIO.dart': Error: line 13 pos 26: type 'HttpClient' is not loaded
var connection = new HttpClient().get('www.google.com', 80, '/');
... que se espera.
Así que mi pregunta es: ¿Cómo importo dart: html & dart: io en la misma clase?
#import('dart:html');
#import('dart:io');
class htmlIO {
ButtonElement _aButton;
htmlIO() {
}
void handlePress(Event e) {
var connection = new HttpClient().get('www.google.com', 80, '/');
write('made it');
}
void run() {
_aButton = document.query("#aButton");
_aButton.on.click.add(handlePress);
write("Hello World!");
}
void write(String message) {
// the HTML library defines a global "document" variable
document.query('#status').innerHTML = message;
}
}
void main() {
new htmlIO().run();
}