在 Flutter 中,调用 Navigator.pop(context) 时,ListView.builder 会闪烁刚刚显示的图片,为什么?

O.M*_*Koh 5 listview flutter

我正在使用ListView.builder()构建图像列表。当使用点击图像时,我将图像放大并通过 flutter 将其显示在照片库中Navigator

这是问题的快速记录:https : //youtu.be/4C5MtXMSwLk

gallery-page.dart where I build the list of images
Widget build(BuildContext context) {    
    return FutureBuilder(
      future: this.futureGalleryImages,
      builder: (BuildContext context, AsyncSnapshot snapshot) {
        switch (snapshot.connectionState) {
          case ConnectionState.waiting:
            return CircularProgressIndicator();            
          default:
            if (snapshot.hasError)
              return Text('Error: ${snapshot.error}');
            else              
              return _createListView(context, snapshot);              
        }
      },
    );
Run Code Online (Sandbox Code Playgroud)

一旦列表视图是构造函数,每个 ListTile 都有 onTap 事件侦听器的打开回调:

void open(BuildContext context, List<GalleryImage> images, final int index){
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => GalleryPhotoViewWrapper(
          galleryItems: images,
          backgroundDecoration: widget.backgroundDecoration,
          initialIndex: index,
          scrollDirection: verticalGallery ? Axis.vertical : Axis.horizontal
        )
      )
    );
  }
Run Code Online (Sandbox Code Playgroud)

然后在GalleryPhotoViewWrapper我监听onVerticalDragUpdate事件并简单地导航回上一个屏幕,这是

ListView:
    children: <Widget>[
                GestureDetector(
                    onVerticalDragUpdate: (dragUpdateDetails) {
                      Navigator.pop(context);
                    },
Run Code Online (Sandbox Code Playgroud)

但是每当Navigator.pop(context)被称为内onVerticalDragUpdate回调时我带回ListView的图像闪烁。我不知道为什么。但是,我确实注意到_createListView当您炸毁图像然后关闭它时会调用回调。我尝试将 ListView 小部件缓存在一个变量中,然后重新显示它,但没有成功。