This recipe shows you the simplest ways to download a file through code, first in a command-line application and then from a web application. As an example, we download the front page of the Learning Dart website from http://learningdart.org.
A client program (be it web or command-line) receives content, such as files or web pages, from a web server using the HTTP protocol. The
dart:io package provides us with the basic classes we need to do this, which are as follows:
dart:core) has all we need to parse, encode, and decode web addresses; the method
Uri.parseis often used
dart:html) has the
getStringmethod to fetch a file from a URL