我想知道如何使用新查询重建FirebaseAnimatedList,新内容更改路径。
new Flexible(
child: new FirebaseAnimatedList(
query: query,
sort: (DataSnapshot a, DataSnapshot b) =>
b.key.compareTo(a.key),
itemBuilder: (BuildContext context, DataSnapshot snapshot,
Animation<double> animation, int index) {...})
当我实时更改查询时,它不会更改列表中的结果:
setState(() {
query = "another/path";
});
答案 0 :(得分:1)
每次更改查询时,我都会通过更改键来工作,我不确定这是否是最好的方法,但是否有效:
new Flexible(
child: new FirebaseAnimatedList(
key: _key,
query: query,
sort: (DataSnapshot a, DataSnapshot b) =>
b.key.compareTo(a.key),
itemBuilder: (BuildContext context, DataSnapshot snapshot,
Animation<double> animation, int index) {...})
setState(() {
query = "another/path";
_key = Key('anotherkey');
});