Parse the Network Response | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/18177023-your-second-flutter-app/lessons/6

Iā€™m facing an issue while I run the app:

Exception has occurred.
SocketException (SocketException: Failed host lookup: ā€˜api.raywenderlich.comā€™ (OS Error: No address associated with hostname, errno = 7))

First i thought I did something wrong, but this occurs on the git courses code too.

In the lesson around 4:30, why do we need to call .toList() in the following code? I think apiResponse["data"] is a list, and calling apiResponse["data"].map() should return a list? Does .toList() changes something in the data type? Thanks for answering @macsimus.

apiResponse["data"]
    .map((json) => courses.add(Course.fromJson(json)))
    .toList();