hyzp_ybqx-Commit159:已修改好today_list_zpjl_content_new.dart。使用自定义 my_flutter_drag_scale 插件,完美解决Listview滚动与图片缩放拖动之间的手势冲突,不会消耗点击事件,滚动很灵敏

This commit is contained in:
WinUser01
2022-05-10 20:35:24 +08:00
parent 13147ebea4
commit 24903d2818
@@ -127,26 +127,45 @@ class _TodayListZpjlPageState extends State<TodayListZpjlContentNew> {
double _radioImage = 9 / 16;
// 使用 cached_network_image 插件实现网络图片缓存
// 使用 flutter_drag_scale 实现可缩放可拖拽双击放大的图片功能。PhotoView插件不好用,有问题
// 使用自定义 my_flutter_drag_scale 插件,完美解决Listview滚动与图片缩放拖动之间的手势冲突,不会消耗点击事件,滚动很灵敏
ScrollPhysics scrollPhysics;
bool bZoomedInit = true; // 图片是否为原样大小
Widget getNetworkImage(String url) {
return CachedNetworkImage(
imageUrl: url,
alignment: Alignment.topCenter,
imageBuilder: (context, imageProvider) => DragScaleContainer(
doubleTapStillScale: true, child: Image(image: imageProvider, fit: BoxFit.fill)
// child: Image(
// image: NetworkImage(
// 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg'),
// ),
),
// imageBuilder: (context, imageProvider) => PhotoView(
// imageProvider: imageProvider,
// ),
//placeholder: (context, url) => CircularProgressIndicator(),
placeholder: (context, url) =>
getMoreWidget(color: Colors.black38, size: 20.0, strokeWidth: 2.0),
errorWidget: (context, url, error) => Icon(Icons.error),
imageBuilder: (context, imageProvider) {
return DragScaleContainer(
doubleTapStillScale: false,
child: Image(image: imageProvider, fit: BoxFit.fill),
scaleChangedCallback: (ScaleChangedModel model) {
print("model.scale = ${model.scale}");
bZoomedInit = (1.0 == model.scale);
scrollPhysics = PageScrollPhysics();
setState(() {});
},
pointerDownCallback: () {
if (bZoomedInit) {
if (scrollPhysics != PageScrollPhysics()) {
scrollPhysics = PageScrollPhysics();
setState(() {});
}
} else {
if (scrollPhysics != NeverScrollableScrollPhysics()) {
scrollPhysics = NeverScrollableScrollPhysics();
setState(() {});
}
}
},
pointerUpCallback: () {
scrollPhysics = PageScrollPhysics();
setState(() {});
},
);
},
);
}
@@ -828,9 +847,12 @@ class _TodayListZpjlPageState extends State<TodayListZpjlContentNew> {
),
)
: SizedBox.shrink(),
KeyboardAvoider(
autoScroll: true,
child: Container(
ListView(
// physics: NeverScrollableScrollPhysics(), // 允许ListView滚动
// physics: null, // 允许ListView滚动
physics: scrollPhysics,
children: [
Container(
color: Color.fromRGBO(244, 244, 244, 1),
child: Column(
children: <Widget>[
@@ -859,6 +881,7 @@ class _TodayListZpjlPageState extends State<TodayListZpjlContentNew> {
],
),
),
],
),
widget.hyshlx == 'tsjj'
? Positioned(