List<Map> imageList = [
{
'provider': const NetworkImage(
"https://img.zcool.cn/community/012c1559b2441ea801211d258355d3.jpg@1280w_1l_2o_100sh.jpg"),
'tag': 'tag1',
'fillScale': PhotoViewComputedScale.covered
},
{
'provider': const NetworkImage(
"http://img.pptjia.com/image/20180117/767f4b74a8d7b453b149430ee364c9ce.jpg"),
'tag': 'tag2',
'fillScale': PhotoViewComputedScale.contained
},
{
'provider': const NetworkImage(
"http://www.hiphotos.baidu.com/image/pic/item/8644ebf81a4c510f3666841a6b59252dd42aa514.jpg"),
'tag': 'tag3',
'fillScale': PhotoViewComputedScale.contained
},
{
'provider':
const NetworkImage("http://www.17qq.com/img_qqtouxiang/30526384.jpeg"),
'tag': 'tag4',
'fillScale': PhotoViewComputedScale.contained
}
];
List<PhotoViewGalleryPageOptions> _takePageOptions(
List<Map> imageProviderList) {
return imageProviderList.map(
(map) {
return PhotoViewGalleryPageOptions(
imageProvider: map['provider'],
minScale: map['fillScale'],
maxScale: PhotoViewComputedScale.covered * 1.1,
initialScale: map['fillScale'],
heroTag: map['tag'],
);
},
).toList();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
constraints: BoxConstraints.expand(
height: MediaQuery.of(context).size.height,
),
child: Stack(
alignment: Alignment.bottomRight,
children: <Widget>[
PhotoViewGallery(
pageOptions: _takePageOptions(widget.imageList),
// pageOptions: <PhotoViewGalleryPageOptions>[
// PhotoViewGalleryPageOptions(
// imageProvider: widget.imageProvider,
// heroTag: "tag1",
// ),
// PhotoViewGalleryPageOptions(
// imageProvider: widget.imageProvider2,
// heroTag: "tag2",
// maxScale: PhotoViewComputedScale.contained * 0.3),
// PhotoViewGalleryPageOptions(
// imageProvider: widget.imageProvider3,
// minScale: PhotoViewComputedScale.contained * 0.8,
// maxScale: PhotoViewComputedScale.covered * 1.1,
// heroTag: "tag3",
// ),
// ],
loadingChild: widget.loadingChild,
backgroundDecoration: widget.backgroundDecoration,
pageController: widget.pageController,
onPageChanged: onPageChanged,
),
Container(
padding: const EdgeInsets.all(20.0),
child: Text(
"Image ${currentIndex + 1}",
style: const TextStyle(
color: Colors.white, fontSize: 17.0, decoration: null),
),
)
],
)),
);
}