-
Book Overview & Buying
-
Table Of Contents
DART Cookbook
By :
In the previous recipe, in step 1, we used a client HttpRequest object and its method getString. In this recipe, we want to download a blob (binarylargeobject) file, for example, a large image, audio, or video file. But first, you need to prepare for this if you need to do more than just download a string from a URL resource to process it on the client. You need to go through the following steps (for the code, see request_prep.dart in the project request_blob).
Create an HttpRequest object as shown in the following code:
import 'dart:html';
void main() {
var path = 'http://learningdart.org';
var request = new HttpRequest();
Open it (here, with the HTTP GET method) as shown in the following code:
request
..open('GET', path)In this stage, we could also have configured its header with the setRequestHeader() method, for example, request.setRequestHeader('Content-type','application/json') when you are sending a JSON string.
Define a callback function, such as requestComplete...
Change the font size
Change margin width
Change background colour