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; double _radioImage = 9 / 16;
// 使用 cached_network_image 插件实现网络图片缓存 // 使用自定义 my_flutter_drag_scale 插件,完美解决Listview滚动与图片缩放拖动之间的手势冲突,不会消耗点击事件,滚动很灵敏
// 使用 flutter_drag_scale 实现可缩放可拖拽双击放大的图片功能。PhotoView插件不好用,有问题 ScrollPhysics scrollPhysics;
bool bZoomedInit = true; // 图片是否为原样大小
Widget getNetworkImage(String url) { Widget getNetworkImage(String url) {
return CachedNetworkImage( return CachedNetworkImage(
imageUrl: url, imageUrl: url,
alignment: Alignment.topCenter, 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) => placeholder: (context, url) =>
getMoreWidget(color: Colors.black38, size: 20.0, strokeWidth: 2.0), getMoreWidget(color: Colors.black38, size: 20.0, strokeWidth: 2.0),
errorWidget: (context, url, error) => Icon(Icons.error), 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,37 +847,41 @@ class _TodayListZpjlPageState extends State<TodayListZpjlContentNew> {
), ),
) )
: SizedBox.shrink(), : SizedBox.shrink(),
KeyboardAvoider( ListView(
autoScroll: true, // physics: NeverScrollableScrollPhysics(), // 允许ListView滚动
child: Container( // physics: null, // 允许ListView滚动
color: Color.fromRGBO(244, 244, 244, 1), physics: scrollPhysics,
child: Column( children: [
children: <Widget>[ Container(
//1、得到格林曼黑度标准和视频播放按钮组件 color: Color.fromRGBO(244, 244, 244, 1),
getHdAndPlay(), child: Column(
//2、得到违章图片组件 children: <Widget>[
imageWztp, //1、得到格林曼黑度标准和视频播放按钮组件
SizedBox(height: ScreenUtil().setHeight(_marginVer)), getHdAndPlay(),
//3、得到违章图片说明信息组件 //2、得到违章图片组件
getWztpSmxx(), imageWztp,
SizedBox(height: ScreenUtil().setHeight(_marginVer)), SizedBox(height: ScreenUtil().setHeight(_marginVer)),
//7、得到黑烟初审信息组件 //3、得到违章图片说明信息组件
widget.hyshlx == 'hycs' || getWztpSmxx(),
widget.hyshlx == 'hyfh' || SizedBox(height: ScreenUtil().setHeight(_marginVer)),
widget.hyshlx == 'tsjj' //7、得到黑烟初审信息组件
? getHyshInfo('hycsInfo') widget.hyshlx == 'hycs' ||
: SizedBox.shrink(), widget.hyshlx == 'hyfh' ||
//8、得到黑烟复审信息组件 widget.hyshlx == 'tsjj'
widget.hyshlx == 'hyfh' || widget.hyshlx == 'tsjj' ? getHyshInfo('hycsInfo')
? getHyshInfo('hyfhInfo') : SizedBox.shrink(),
: SizedBox.shrink(), //8、得到黑烟复审信息组件
SizedBox(height: widget.hyshlx == 'tsjj' ? 0 : 15), widget.hyshlx == 'hyfh' || widget.hyshlx == 'tsjj'
//9、得到推送交警确认组件 ? getHyshInfo('hyfhInfo')
getTsjjQr(), : SizedBox.shrink(),
//SizedBox(height: 10), SizedBox(height: widget.hyshlx == 'tsjj' ? 0 : 15),
], //9、得到推送交警确认组件
getTsjjQr(),
//SizedBox(height: 10),
],
),
), ),
), ],
), ),
widget.hyshlx == 'tsjj' widget.hyshlx == 'tsjj'
? Positioned( ? Positioned(