MultipartRequest class Null safety

A multipart/form-data request.

Such a request has both string fields, which function as normal form fields, and (potentially streamed) binary files.

This request automatically sets the Content-Type header to multipart/form-data. This value will override any value set by the user.

var uri = Uri.parse('');
var request = http.MultipartRequest('POST', uri)
  ..fields['user'] = ''
  ..files.add(await http.MultipartFile.fromPath(
      'package', 'build/package.tar.gz',
      contentType: MediaType('application', 'x-tar')));
var response = await request.send();
if (response.statusCode == 200) print('Uploaded!');


MultipartRequest(String method, Uri url)


contentLength int
The total length of the request body, in bytes. [...]
read / write, override
fields Map<String, String>
The form fields to send for this request.
files List<MultipartFile>
The list of files to upload for this request.
finalized bool
Whether finalize has been called.
read-only, inherited
followRedirects bool
Whether the client should follow redirects while resolving this request. [...]
read / write, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
headers Map<String, String>
final, inherited
maxRedirects int
The maximum number of redirects to follow when followRedirects is true. [...]
read / write, inherited
method String
The HTTP method of the request. [...]
final, inherited
persistentConnection bool
Whether a persistent connection should be maintained with the server. [...]
read / write, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
url Uri
The URL to which the request will be sent.
final, inherited


finalize() ByteStream
Freezes all mutable fields and returns a single-subscription ByteStream that will emit the request body.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
send() Future<StreamedResponse>
Sends this request. [...]
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]