如何在Flutter中突出显示ListView的顶部项 [英] How to highlight top item of ListView in flutter

查看:98
本文介绍了如何在Flutter中突出显示ListView的顶部项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个Listview,其顶部元素应该具有与其余元素不同的UI.并且Listview是可滚动的,因此应该使用不同的UI突出显示列表顶部和顶部的项目.请参阅此图像.

I'm trying to make a Listview whose top element should have a different UI then the rest. And the Listview is scrollable so the item which is visible and at the top of the list should be highlighted with different UI. Refer to this image.

我希望在列表中滚动时,那一刻的顶部项目应该具有不同的UI(突出显示的橙色).

I want when I scroll through the list the top item at that instant should have a different UI ( the highlighted orange color).

我该怎么办呢?

推荐答案

这仍然是开放的Github问题.

但是,在此处有一些软件包可以帮助您实现这一点(不确定长列表的性能).

However, there are some packages here that can help you achieve this (Not sure about the performance with long lists).

请从上面的链接中查看 scrollable_positioned_list .它提供了一个侦听器,可通过该侦听器监视可见项,如下所示:

Do check out the scrollable_positioned_list from the above link. It provides a listener by which the visible items can be monitored as follows:

itemPositionsListener.positions.addListener((positions) => ...);

这篇关于如何在Flutter中突出显示ListView的顶部项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆