【发布时间】:2020-04-18 20:03:28
【问题描述】:
这个函数会产生错误:
static Future<String> createTable() async {
try {
var map = Map<String, dynamic>();
map['action'] = 'CREATE_TABLE';
final response = await http.post(ROOTurl, body: map);
print('Create Table Response: ${response.body}');
if (200 == response.statusCode) {
return response.body;
} else {
return "error";
}
} catch (e) {
return "error"+e;
}}
完全例外:
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'SocketException' is not a subtype of type 'String'
有什么办法可以解决这个问题?
【问题讨论】:
-
而不是'return "error"+e'尝试写'return "error ${e.message}"'