The python example related to the question includes requesting the contents of example.com and writing the response to the file.
Here's how you can do something like this in Dart:
import 'dart:io'; main() { var url = Uri.parse('http://example.com'); var httpClient = new HttpClient(); httpClient.getUrl(url) .then((HttpClientRequest request) { return request.close(); }) .then((HttpClientResponse response) { response.transform(new StringDecoder()).toList().then((data) { var body = data.join(''); print(body); var file = new File('foo.txt'); file.writeAsString(body).then((_) { httpClient.close(); }); }); }); }
source share