我正在使用ListView.builder()
来构建图像列表。在图像上使用水龙头时,我将图像放大并通过抖动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);
}
},
);
一旦列表视图成为构造函数,则每个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
)
)
);
}
然后在GalleryPhotoViewWrapper
中,我监听onVerticalDragUpdate
事件,然后简单地导航回到上一个屏幕,即
ListView:
children: <Widget>[
GestureDetector(
onVerticalDragUpdate: (dragUpdateDetails) {
Navigator.pop(context);
},
但是,每当在Navigator.pop(context)
回调内部调用onVerticalDragUpdate
时,当我回到ListView时,图像都会闪烁。我不知道为什么。但是,我确实注意到,_createListView
回调在放大图像然后将其关闭时被调用。我尝试将ListView小部件缓存在一个变量中,然后重新显示它,但没有成功。