Open bobqiu opened 1 week ago
代码中筛选条件没有正确完成更新(这个可以自己输出看一下):
spinnerEntities = data;
建议使用:
commonPageVm.conditions.replaceRange()
。
你需要做的是正确替换commonPageVm.conditions
,而不是修改临时变量。
对于网络数据直接fromJson
的情况当时确实没去考虑,后面抽时间会对这个json解析处理一下,尽量避免额外再去处理一次数据。
好的,谢谢
通过服务器接口返回以下数据结构,目标通过mvvc模式进行配置实现筛选框的功能,查询条件为“审批状态和自定义查询”:
{ "code": 0, "data": [ { "name": "审批状态", "spinnerEntities": [ { "key": "spinnerentity3", "title": "this is title23", "extraData": "this is extradata23", "type": "MoreContentType.column", "desc": "imya23", "titleSuffix": null, "items": [ { "name": "审批中", "result": "审批中", "items": null, "selected": false, "selectedAll": false, "isMutex": "false" }, { "name": "正在审批", "result": "正在审批", "items": null, "selected": false, "selectedAll": false, "isMutex": "false" } ], "isRadio": "false" } ] }, { "name": "自定义查询", "spinnerEntities": [ { "key": "spinnerentity", "title": "this is title", "extraData": "this is extradata", "type": "MoreContentType.wrap", "desc": "imya", "titleSuffix": null, "items": [ { "name": "spinneritem2", "result": "spinneritem2", "items": [ { "name": "spinneritem0", "result": "spinneritem0", "items": null, "selected": false, "selectedAll": false, "isMutex": "true" }, { "name": "spinneritem1", "result": "spinneritem1", "items": null, "selected": false, "selectedAll": false, "isMutex": "true" } ], "selected": false, "selectedAll": false, "isMutex": "true" }, { "name": "spinneritem3", "result": "spinneritem3", "items": null, "selected": false, "selectedAll": false, "isMutex": "true" } ], "isRadio": "true" }, { "key": "spinnerentity2", "title": "this is title2", "extraData": "this is extradata2", "type": "MoreContentType.wrap", "desc": "imya2", "titleSuffix": null, "items": [ { "name": "spinneritem2", "result": "spinneritem2", "items": [ { "name": "spinneritem0", "result": "spinneritem0", "items": null, "selected": false, "selectedAll": false, "isMutex": "true" }, { "name": "spinneritem1", "result": "spinneritem1", "items": null, "selected": false, "selectedAll": false, "isMutex": "true" } ], "selected": false, "selectedAll": false, "isMutex": "true" }, { "name": "spinneritem3", "result": "spinneritem3", "items": null, "selected": false, "selectedAll": false, "isMutex": "true" } ], "isRadio": "true" } ] } ], "msg": "" }
在查询页面做了以下修改: ‘class ConditionWidget extends StatefulWidget { const ConditionWidget({super.key});
@override State createState() => _ConditionWidgetState();
}
class _ConditionWidgetState extends State {
@override
void initState() {
super.initState();
}
Map<String, List> _result = {};
@override Widget build(BuildContext context) { return ProviderWidget(
viewModel: CommonPageVm(),
builder: (context, commonPageVm, _) {
// debugPrint("@@@@@@@@@@@@@@@@@@@@@commonPageVm.conditionName:${commonPageVm.conditionName.isEmpty}");
if (commonPageVm.conditionName.isEmpty) {
return Container();
}
return SpinnerBox.rebuilder(
titles: commonPageVm.conditionName,
builder: (notifier) {
List widgets = [];
for (List spinnerEntities
in commonPageVm.conditions) {
SpinnerPopScope spinnerWidget = SpinnerFilter(
data: spinnerEntities,
onCompleted: (result, name, data, onlyClosed) {
notifier.updateName(name);
setState(() {
spinnerEntities = data;
_result = result;
});
},
).heightPart;
widgets.add(spinnerWidget);
}
return widgets.toList();
},
);
},
);
}
}’
下拉筛选框的显示及选择都能正常显示或得到结果,但是再次点击下拉框时选择项不能在查询条件窗口正常回显。
尝试了很多方法找不到解决方案,有没有示例程序做为参考或者怎样修改 谢谢!