dart language: Map<Object,String> how to add new pair?

dart, dictionary

Solution

Maybe it helps

final test = Map<String, int>();
test.putIfAbsent('58', () => 56);

if key doesn't exist, it will be putted into map.

Problem

Given: ``` Map<WebSocket,String> mListUser; mListUser= new Map<WebSocket,String>(); ``` From what i understood now to add a new element i should just do: ``` mListUser[socket]="string"; ``` instead im getting: ``` type 'String' is not a subtype of type 'int' of 'index'. ``` What am i doing wrong?

Original source