toForm method Null safety

  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 image in images) {
    String? mime = lookupMimeType(image);
    form.add(
      MBMultipartForm.file(
        "$parameterName[$index]",
        image,
        mime != null
            ? MediaType.parse(mime)
            : MediaType('application', 'octet-stream'),
      ),
    );
    index++;
  }
  return form;
}