Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 如何在Futurebuilder中的ListView上使用Refreshindicator?_Firebase_Flutter - Fatal编程技术网

Firebase 如何在Futurebuilder中的ListView上使用Refreshindicator?

Firebase 如何在Futurebuilder中的ListView上使用Refreshindicator?,firebase,flutter,Firebase,Flutter,我很难重新加载我的列表,这是一个未来建设者的孩子 我目前正在使用来自futureprovider的数据,我知道这些数据可能是不必要的,但我想学习它并暂时将其留在那里。(这可能是个问题吗?) 如您所见,我有两个ListView,一个嵌套在另一个中。我想将顶级ListView包装在RefreshIndicator中以从Firebase加载新数据,但我不知道如何以及在何处更新数据 class _DayTransferListState extends State<DayTransferList&

我很难重新加载我的列表,这是一个未来建设者的孩子

我目前正在使用来自futureprovider的数据,我知道这些数据可能是不必要的,但我想学习它并暂时将其留在那里。(这可能是个问题吗?)

如您所见,我有两个ListView,一个嵌套在另一个中。我想将顶级ListView包装在RefreshIndicator中以从Firebase加载新数据,但我不知道如何以及在何处更新数据

class _DayTransferListState extends State<DayTransferList> {

  @override
  Widget build(BuildContext context) {
    final days = Provider.of<List<Day>>(context);        //<-- i am populating my list with this data atm
    return FutureBuilder(
      future: DatabaseService().dayTransferData(),      //<-- dayTransferData returns a Future<List<Day>>
      builder: (BuildContext context, AsyncSnapshot snapshot) {
        switch (snapshot.connectionState) {
          case ConnectionState.waiting:
            //...
          default:
            if (snapshot.hasError) {
              return Text('haserror');
            } else {
              return RefreshIndicator(                    //<-- refreshindicator
                onRefresh: () async {
                  _refreshItems;
                },
                child: ListView.builder(
                  physics: BouncingScrollPhysics(),
                  itemCount: days.length,
                  itemBuilder: (
                    BuildContext context,
                    int dayindex,
                  ) {
                    return Column(
                      children: <Widget>[
                        //...
                        Container(
                          width: double.infinity,
                          padding: EdgeInsets.all(10),
                          decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.circular(kButtonRadius),
                          ),
                          child: ListView.builder(                          //<-- second, nested ListView
                            physics: ClampingScrollPhysics(),
                            shrinkWrap: true,
                            itemCount: days[dayindex].transfers.length,
                            itemBuilder: (BuildContext context, int index) {
                              return TransactionTile(
                                transactionIndex: index,
                                dayIndex: dayindex,
                                transfer: days[dayindex].transfers[index],
                              );
                            },
                          ),
                        ),
                      ],
                    );
                  },
                ),
              );
            }
        }
      },
    );
  }

  Future _refreshItems() async {                                       //<-- method called in "onRefresh"
    await DatabaseService().dayTransferData();          //<-- dayTransferData returns a Future<List<Day>>
    setState(() {});
    return null;
  }
}
class\u DayTransferListState扩展了状态{
@凌驾
小部件构建(构建上下文){

final days=Provider.of(context);//它不适用于builder.do

ListView(
子项:List.generate(/*…*/),
)