将静态元素添加到由futurebuilder在flutter中构建的gridview?

Adding static element to gridview which is constructed by futurebuilder in flutter?

我正在使用 gridview 和 futurebuilder 获取图像。但是我需要添加一张静态 photo.I 替换来自 futurebuilder 的照片,但我还想添加一张来自 futurebuilder 外部的静态照片。 这就是我希望我的 gridview 的样子:

我想将这张图片添加到gridview:

这是我的代码:

    ...
    future: future,
                          builder: (ctx, snapshot) => snapshot.connectionState ==
                                  ConnectionState.waiting
                              ? Center(
                                  child: CircularProgressIndicator(),
                                )
                              : Column(
                                  children: [
                                    Flexible(
                                      flex: 5,
                                      child: Container(
                                        padding: EdgeInsets.only(
                                            top: 40,
                                            bottom: 1,
                                            left: 40,
                                            right: 40),
                                        child: Consumer<Images>(
                                          builder: (ctx, titles, ch) =>
                                              GridView.builder(
                                                  physics: ScrollPhysics(),
                                                  itemCount: titles.items.length,
                                                  gridDelegate:
                                                      SliverGridDelegateWithFixedCrossAxisCount(
                                                    crossAxisCount: getSize(
                                                        _currentSliderValue),
                                                    mainAxisSpacing: 50,
                                                    childAspectRatio: 115 / 162.05,
                                                    crossAxisSpacing: 5,
                                                  ),
                                                  itemBuilder: (ctx, index) {
                                                    saveallimages(titles.items);
    
                                                    return GestureDetector(
                                                        onTap: () => add(titles
                                                            .items[index].image),
                                                        //()=>add(titles.items[index].image),
                                                        child: selected.contains(
                                                                titles.items[index]
                                                                    .image.path
                                                                    .toString())
                                                            ? Container(
                                                                child: selectedimage(
                                                                    titles
                                                                        .items[
                                                                            index]
                                                                        .image))
                                                            : Container(
                                                                child: nonselected(
                                                                    titles
                                                                        .items[
                                                                            index]
                                                                        .image)));
                                                  }),
...

itemCount 增加 1。在 itemBuilder 中检查是否 index == titles.items.length,如果是则显示您的静态项目。