Error ‘A value of type ‘dynamic’ can’t be assigned to a variable of type ‘String’.’

A value of type 'dynamic' can't be assigned to a variable of type 'Map<String, dynamic>'. Try changing the type of the variable, or casting the right-hand type to 'Map<String, dynamic>'.

// Get Channel
var response = await http.get(uri, headers: headers);
if (response.statusCode == 200) {
  Map<String, dynamic> data = json.decode(response.body)['items'][0] ;
  Channel channel = Channel.fromMap(data);

Read more here:

Content Attribution

This content was originally published by Mohammad Zakir Raza at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: