我的代码中出现此错误。
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'FutureOr<List<dynamic>>'
这是我的代码:
Future<List> getmatches() async{
String url="https://cricapi.com/api/cricketScore?apikey=oJmzPtpZJXcIQmxAjOlP5Zss1At1&unique_id=1034809";
http.Response response=await http.get(url);
return jsonDecode(response.body);
这是错误:
Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a
subtype of type 'FutureOr<List<dynamic>>'
答案 0 :(得分:0)
将函数的返回类型替换为Future<Map<String, dynamic>>
,使它看起来像
Future<Map<String, dynamic>> getmatches() async {
String url="https://cricapi.com/api/cricketScore?apikey=oJmzPtpZJXcIQmxAjOlP5Zss1At1&unique_id=1034809";
http.Response response=await http.get(url);
return jsonDecode(response.body);
}