【发布时间】:2020-06-18 18:01:26
【问题描述】:
我遇到了这个错误,谁能帮我解决这个错误
static Future<String> get_video_lecture_subject(int schoolId,int classroom) async {
var body;
body = jsonEncode({
"school_id": schoolId,
"classroom": classroom,
});
final response = await http.post(
'https://b5c4tdo0hd.execute-api.ap-south-1.amazonaws.com/testing/get-video-lecture-subjects',
headers: {"Content-Type": "application/json"},
body: body,
);
print(response.body.toString());
return response.body.toString();
}
我在 getpref() 函数中使用了上述函数
getpref() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
int classNo = int.parse(prefs.getString("class")[0]);
int schoolId = prefs.getInt("school_id");
print("hello");
response=(await ApiService.get_video_lecture_subject(schoolId, classNo)) as Future<String> ;
print(response);
}
【问题讨论】:
-
print(response.toString()) 会导致同样的错误吗?
-
它打印,但有效,但
-
response=(await ApiService.get_video_lecture_subject(schoolId, classNo)) as Future
; , -
此行导致错误
-
String response=await ApiService.get_video_lecture_subject(schoolId, classNo);