The answer its actually what Flutter has suggested in this part of exception message
:
'_InternalLinkedHashMap<String, Object>' is not a subtype of type 'Map<String, String>'
What does it mean ?
It means that, one of your variable is '_InternalLinkedHashMap<String, Object>'
and flutter wants you to change it to 'Map<String, String>'
type
You should make one of your key in queryParameters
to this 'Map<String, String>'
type
How ?
1. Import Dart Convert
by importing dart:convert
, we will have jsonEncode
method
import 'dart:convert'; // put this at top of your file
2. Convert Nested Value, to String
final nestedValue = {
"login": "login",
"password": "pwd",
};
String stringValue = jsonEncode(nestedValue);
3. Put it back to your main Parameters
final queryParameters = {
"id": "6767676767676",
"device": "tatatata",
"user": stringValue
};
final uri = Uri.http('44.44.444.444:8080', 'get-answer', queryParameters);
Final Code
This will be your final code looks like below :
import 'dart:convert'; // put this at top of your file
final nestedValue = {
"login": "login",
"password": "pwd",
};
String stringValue = jsonEncode(nestedValue); // add this
final queryParameters = {
"id": "6767676767676",
"device": "tatatata",
"user": stringValue
};
final uri = Uri.http('44.44.444.444:8080', 'get-answer', queryParameters);