0

I have a map like:

Map<String, dynamic> myMap; // do something to add data to myMap

I want to update a key:value in myMap, i tried:

myMap.update(mykey, '0' as dynamic);

But i recive an error:

Unhandled Exception: type 'String' is not a subtype of type '(dynamic) => dynamic'

3
  • if you want to pass string then use Map<String, String> instead of dynamic. Commented Oct 13, 2019 at 16:11
  • I cannot do it, because data from json is dynamic Commented Oct 13, 2019 at 16:17
  • stackoverflow.com/questions/53376518/… see here looks like same question. Commented Oct 13, 2019 at 16:34

1 Answer 1

1

Map.update takes a function as its second argument. It doesn't seem like you need to use Map.update; you can just do myMap[myKey] = '0';.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.