fix: 动态刷新时顶栏不刷新bug

This commit is contained in:
orz12
2024-03-02 13:12:25 +08:00
parent 7ecd2f48e5
commit cc208b1182

View File

@@ -30,27 +30,15 @@ class _UpPanelState extends State<UpPanel> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
upList = widget.upData!.upList!;
if (widget.upData!.liveUsers != null) {
liveList = widget.upData!.liveUsers!.items!;
}
upList.insert(
0,
UpItem(face: '', uname: '全部动态', mid: -1),
);
userInfo = userInfoCache.get('userInfoCache'); userInfo = userInfoCache.get('userInfoCache');
upList.insert(
1,
UpItem(
face: userInfo.face,
uname: '',
mid: userInfo.mid,
),
);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
upList = widget.upData!.upList!;
if (widget.upData!.liveUsers != null) {
liveList = widget.upData!.liveUsers!.items!;
}
return SliverPersistentHeader( return SliverPersistentHeader(
floating: true, floating: true,
pinned: false, pinned: false,
@@ -110,8 +98,17 @@ class _UpPanelState extends State<UpPanel> {
.withOpacity(0.5), .withOpacity(0.5),
), ),
], ],
upItemBuild(
UpItem(face: '', uname: '全部动态', mid: -1), 0),
upItemBuild(
UpItem(
face: userInfo.face,
uname: '',
mid: userInfo.mid,
),
1),
for (int i = 0; i < upList.length; i++) ...[ for (int i = 0; i < upList.length; i++) ...[
upItemBuild(upList[i], i) upItemBuild(upList[i], i + 2)
], ],
const SizedBox(width: 10), const SizedBox(width: 10),
], ],