Using dart to download a file

dart

Solution

Shailen's response is correct and can even be a little shorter with Stream.pipe.

import 'dart:io';

main() async {
  final request = await HttpClient().getUrl(Uri.parse('http://example.com'));
  final response = await request.close();
  response.pipe(File('foo.txt').openWrite());
}

Problem

Can we use `dart` to download a file? For example in python

Original source