Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Dio doesn't accept int value as queryParameters

Tags:

flutter

dart

I'm making a call using Dio that send some query parameters, using map constructor

  response = await Dio().get(url, queryParameters: {
    "apikey": publicKey,
    "hash": hash,
    "ts": timestamp,
    "nameStartsWith": searchTerm
  });

Everything works correctly, but when try to send a int value, Dio throw a error

  response = await Dio().get(url, queryParameters: {
    "apikey": publicKey,
    "hash": hash,
    "ts": timestamp,
    "nameStartsWith": searchTerm,
    "page" : 10
  });

type 'int' is not a subtype of type 'Iterable < dynamic > '#0

And i can't just convert the int value to string, because api is expcting int type.

Any help ?

like image 487
cesarsicas Avatar asked Feb 05 '19 19:02

cesarsicas


1 Answers

There is no such thing as an int type in an URL and therefore in query parameters.
An URL can only be a String.

Just convert it to String and be done.

like image 116
Günter Zöchbauer Avatar answered Nov 08 '22 20:11

Günter Zöchbauer