when i print _images list it shows that 'instance of multipart' and when i send list of imageFileList this doesn't accept by server.
also what is the use of multipart in sending images? here is the response error from server response from server error 500
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:shared_preferences/shared_preferences.dart';
var token;
Dio dio = Dio();
List<dynamic>? _images = [];
var apiURL = 'https://denga.r3therapeutic.com/public/api/addpost';
FormData formData = FormData();
Future<String> adminAddproperty({
title,
address,
price,
area,
bedrooms,
bathrooms,
parking,
other,
description,
List<File>? imageFileList,
context,
}) async {
for (int i = 0; i < imageFileList!.length; i++) {
var image = imageFileList[i].path;
_images!.add(
await MultipartFile.fromFile(image, filename: image.split('/').last));
}
FormData formData = FormData.fromMap({
'title': title,
'address': address,
'price': price,
'area': area,
'bedrooms': bedrooms,
'bathrooms': bathrooms,
'parking': parking,
'others': other,
'description': description,
'images[]': imageFileList,
});
SharedPreferences pref = await SharedPreferences.getInstance();
token = pref.getString('token');
print('AdminApisToken =$token');
print('_images');
Response responce;
responce = await dio.post(apiURL,
data: formData,
options: Options(headers: {
HttpHeaders.authorizationHeader: "Bearer $token",
}));
print('Responce: $responce');
return '';
}