appendFile method

void appendFile(
  1. String key,
  2. File file, {
  3. MediaType? contentType,
  4. String? filename,
})

Appends a new file onto an existing key inside a FormData object, or adds the key if it does not already exist. In opposite to the append method, it has additional settings related to the file.

Implementation

void appendFile(
  String key,
  File file, {
  MediaType? contentType,
  String? filename,
}) {
  ArgumentError.checkNotNull(key, 'key');
  ArgumentError.checkNotNull(file, 'file');

  final fileField = FileField(
    file: file,
    filename: filename,
    contentType: contentType,
  );

  _addEntry(key, fileField);
}