Il codice di seguito "guarda a destra", si compila, ma non viene eseguito, non riuscendo con il messaggio console:Come posso importare dart: html e dart: io nella stessa classe?
Cannot load Dart script dart:io
Failed to load resource
Se commento fuori la #import('dart:io');
, sbagliato io credo, ottengo un errore di compilazione, ma si avvia e non finché non preme il pulsante, ottengo l'errore di runtime:
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, '/');
... che è previsto.
Quindi la mia domanda è: come posso importare dart: html & dart: io nella stessa classe?
#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();
}