Unhandled Exception: InternalLinkedHashMap' is not a subtype of type 'List

前端 未结 9 737
夕颜
夕颜 2020-12-15 16:04

I am trying to get the JSON response from the server and output it to the console.

Future login() async {
    var response = await http.get(
            


        
9条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 16:23

    You can get this error if you are using retrofit.dart and declare the wrong return type for your annotated methods:

    @GET("/search")
    Future> getResults(); 
    // wrong! search results contains a List but the actual type returned by that endpoint is SearchResults 
    

    vs

    @GET("/search")
    Future getResults(); 
    // correct for this endpoint - SearchResults is a composite with field for the list of the actual results
    

提交回复
热议问题