this is how i am post in data to server
var request = new http.MultipartRequest("POST", uri);
request.headers.addAll(headers);
request.fields['property_id'] = property_id; //value from textcontroller
request.fields['unit_id'] = unitlist; //value from textcontroller
request.fields['tenant_name'] = tenant_name; //value from textcontroller
request.fields['additional_terms'] = addistiona_tems;//value from textcontroller
var stream = new http.ByteStream(DelegatingStream.typed(file.openRead()));
var length = await file.length();
var tenantimage = new http.MultipartFile('Tenant_image', stream, length,
filename: basename(file.path));
request.files.add(tenantimage);
var response = await request.send();
this is my result when i return sending value as response
Array
(
[property_id] => 2
[unit_id] => 1463
[tenant_name] => aqws
[additional_terms] => awedswer
)
but i want achieve as "unit_id" and "additional_terms" as array? like this
Array
(
[property_id] => 2
[unit_id] => Array
(
[0]
)
[tenant_name] => aqws
[additional_terms] => Array
(
[0]=> awedswer
[1]=> bilk
)
)
Solution 1: hio
try this:-
request.fields['additional_terms'] = "[{"shop_id":"1","product_id":1,"unit_price":188.0,"quantity":1,"discounted_price":0.0}]"