eli2003
eli2003

Reputation: 400

Flutter Unhandled error type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Map<String, String>'

When calling http.get using the Flutter http package, the following exception gets thrown:

Unhandled Exception: Unhandled error type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Map<String, String>' occurred in bloc Instance of 'AccountsBloc'.

The code which throws the exception

final response = await http.get(
  serverConfig.url,
  headers: _getHeaders(username, password),
);

Map<String, dynamic> _getHeaders(String username, String password) {
  return {
    "apikey": serverConfig.apiKey,
    "action": "login",
    "user": username,
    "pass": password
  };
}

It seems that _getHeaders() is causing this problem, when it's called according to the console output.

Upvotes: 0

Views: 148

Answers (1)

Vilsad P P
Vilsad P P

Reputation: 1559

try

Map<String, String> _getHeaders(String username, String password) {
  return {
    "apikey": serverConfig.apiKey,
    "action": "login",
    "user": username,
    "pass": password
  };
}

Upvotes: 1

Related Questions