ModuleList.fromResult constructor
ModuleList.fromResult(
- List<
RespType> ? result
Implementation
factory ModuleList.fromResult(List<RespType<dynamic>>? result) {
if (result == null) return ModuleList(list: []);
List<ModuleListInfo> _list = result.map((item) {
var item1 = item as RespArray;
final payload1 = item1.payload;
// 确保 payload1 不为空,并且至少有 4 个元素
if (payload1 != null && payload1.length > 3) {
return ModuleListInfo(
name: payload1[1].payload?.toString() ?? '',
ver: payload1[3].payload as int? ?? 0,
);
} else {
// 如果 payload 不符合预期,可以返回一个默认值或其他处理逻辑
return ModuleListInfo(name: 'Unknown', ver: 0);
}
}).toList(growable: false);
return ModuleList(list: _list);
}