我有以下小部件:
class _PhotoViewState extends State<PhotoView> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.passthrough,
children: [
PhotoViewGallery.builder(
itemCount: widget.imageUrls.length,
builder: (context, index) {
return PhotoViewGalleryPageOptions(
imageProvider:
CachedNetworkImageProvider(widget.imageUrls[index]),
initialScale: PhotoViewComputedScale.contained,
minScale: PhotoViewComputedScale.contained,
maxScale: PhotoViewComputedScale.covered * 2,
);
},
scrollPhysics: const BouncingScrollPhysics(),
backgroundDecoration: const BoxDecoration(color: Colors.black),
loadingBuilder: (context, event) => Center(
child: Container(
width: 20.0,
height: 20.0,
child: CircularProgressIndicator(
value: event == null
? 0
: event.cumulativeBytesLoaded / event.expectedTotalBytes!,
),
),
),
),
Positioned(
top: 0,
left: 0,
right: 0,
bottom: 0,
child: Container(
color: Colors.green.withOpacity(0.5),
child: Text("This is an overlay"),
),
),
],
),
);
}
}
Photoview会返回一个图片大小的Widget,这通常意味着有很多多余的空间。我尝试实现的是一个容器,它可以覆盖整个屏幕,除了照片,当触摸它时,屏幕会弹出。然而,正如你在下面的图片中看到的,我的容器占据了整个屏幕,并位于图片的顶部。
有人知道我怎么做才能让容器避开图像吗?
谢谢!
1条答案
按热度按时间hof1towb1#
您可以重新订购
stack's children
,使绿色容器位于图像下方: