WallPaper_ZZH_Flutter/wallpaper/lib/pages/imgscanpage/imgscanpage_view.dart
2024-05-13 17:10:35 +08:00

56 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:wallpaper/models/imgnetodel.dart';
import 'package:photo_view/photo_view.dart';
import 'package:photo_view/photo_view_gallery.dart';
class ImgScanPageView extends GetView {
final NetImgCategory dataModel;
final int currentIndex;
const ImgScanPageView({super.key,required this.dataModel,required this.currentIndex});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("查看大图"),
),
body: Container(
child: PhotoViewGallery.builder(
scrollPhysics: const BouncingScrollPhysics(),
builder: (BuildContext context, int index) {
return PhotoViewGalleryPageOptions(
imageProvider: NetworkImage(dataModel.data![index].original!),
initialScale: PhotoViewComputedScale.contained * 0.8,
minScale: PhotoViewComputedScale.contained*0.4,
maxScale: PhotoViewComputedScale.contained * 4,
// heroAttributes: PhotoViewHeroAttributes(tag: galleryItems[index].id),
);
},
itemCount: dataModel.data!.length,
loadingBuilder: (context, event) => Center(
child: Container(
width: 20.0,
height: 20.0,
child: CircularProgressIndicator(
value: event == null
? 0
: event.cumulativeBytesLoaded / event.expectedTotalBytes!,
),
),
),
// backgroundDecoration: widget.backgroundDecoration,
// pageController: widget.pageController,
onPageChanged: onPageChanged,
)
),
);
}
void onPageChanged(int index){
print("点击了图片....");
}
}