孔洞逻辑完成

This commit is contained in:
mmc
2026-03-03 09:40:29 +08:00
parent bb16a532ec
commit ca90d8dc05
7 changed files with 134 additions and 116 deletions

View File

@@ -19,22 +19,24 @@ class PathHttpDatasourceImpl implements PathHttpDatasource {
// 1. 先打印基础信息
print('=== 最终发送给后端的请求体 ===');
print('请求体类型:${body.runtimeType}');
print('是否包含holes:${body.containsKey('holes')}, holes长度:${(body['holes'] as List).length}');
// 2. 格式化打印JSON(带缩进,清晰展示嵌套结构)
final jsonString = const JsonEncoder.withIndent(' ').convert(body);
print('完整JSON请求体:\n$jsonString');
final _jsonString = jsonEncode(body);
print('完整JSON请求体:\n$jsonString');
// 3. 可选:单独打印holes的JSON(重点关注)
final holesJson = body['holes'] as List;
print('=== 单独打印holes的JSON ===');
if (holesJson.isEmpty) {
print('holes 为空数组');
} else {
for (int i = 0; i < holesJson.length; i++) {
print('第${i + 1}组hole:\n${const JsonEncoder.withIndent(' ').convert(holesJson[i])}');
}
}
//final holesJson = body['holes'] as List;
//print('=== 单独打印holes的JSON ===');
//if (holesJson.isEmpty) {
// print('holes 为空数组');
//} else {
// for (int i = 0; i < holesJson.length; i++) {
// print('第${i + 1}组hole:\n${const JsonEncoder.withIndent(' ').convert(holesJson[i])}');
// }
//}
} catch (e) {
// 防止JSON序列化失败导致崩溃
print('打印请求体失败:$e');