toForm method

  1. @override
List<MBMultipartForm>? toForm()
override

Converts the element to an array of MBMultipartForm representing it.

Implementation

@override
List<MBMultipartForm>? toForm() {
  List<MBMultipartForm> form = [];
  int index = 0;
  for (String file in files) {
    String? mime = lookupMimeType(file);
    form.add(
      MBMultipartForm.file(
        "$parameterName[$index]",
        file,
        mime != null
            ? MediaType.parse(mime)
            : MediaType('application', 'octet-stream'),
      ),
    );
    index++;
  }
  return form;
}