I have this key value pairs I wanted to send to the server :

String brand = "sony";

  double price_val = 0.01,
      ram_val = 0.01,
      internal_val = 0.01,
      kamera_val = 0.01;

var arguments = {
  "brand": brand,
  "price": price_val,
  "ram": ram_val,
  "internal": internal_val,
  "kamera": kamera_val
};

But i got this error :

Error : type 'double' is not a subtype of type 'String' in type cast

If I changed it to .toString(), the server will give another error because the values need to be double. How can I send exactly with those values?

EDIT

it looks like it gave an error on the http request :

http.post(url,
        body: arguments,
        headers: {"Content-Type": "application/json"}).then((onValue) {
      Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => ResultPage(
                    onValue.body,
                  )));
});


Solution 1: Michael Yuwono

Define the arguments type explicitly

final arguments = <String, Object>{
  "brand": brand,
  "price": price_val,
  "ram": ram_val,
  "internal": internal_val,
  "kamera": kamera_val
};


Solution 2: Cobolt

You can use the dynamic keyword:

final arguments = <String, dynamic>{
  "brand": brand,
  "price": price_val,
  "ram": ram_val,
  "internal": internal_val,
  "kamera": kamera_val
};


Solution 3: zakwan dhiyaulhaq

if you set application/json as a content type in your request header, you need to encode your request body to json using jsonEncode

here are the example

http.post(url,
        body: jsonEncode(arguments),
        headers: {"Content-Type": "application/json"}).then((onValue) {
      Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => ResultPage(
                    onValue.body,
                  )));
});