我一直在寻找一种方法,能够永久地将所选项目移动到flutter中ListView的顶部。
通过按下ListView
元素旁边的一个iconbutton
,并在refresh
时将该元素移到顶部,即可实现此功能。
如果可能的话,当图标按钮处于启用状态时,它应该变为enabled
(即发光/亮起),而在禁用状态下则应变为disabled
(变灰,但仍可按下)。
由于我无法在此问题中放入所有代码,因此其中所有内容以及_getListItemUi
都可在https://github.com/Jak3-02/myproject2上找到。
这是我的当前ListView的样子:
Widget _cryptoWidget() {
return new Container(
child: new Column(
children: <Widget>[
new Flexible(
child: new ListView.builder(
itemCount: _currencies.length,
itemBuilder: (BuildContext context, int index) {
final int i = index ~/ 2;
final Crypto currency = _currencies[i];
final MaterialColor color = _colors[i % _colors.length];
if (index.isOdd) {
return new Divider();
}
return _getListItemUi(currency, color);
},
),
),
],
)
);
}
谢谢,非常感激所有的想法。 :)
ListView
的第一级子项使用。 - Jacob Phillips