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

This commit is contained in:
WinUser01
2022-05-10 20:24:10 +08:00
parent 7cbc6127e9
commit 2fb22de8a5
2 changed files with 75 additions and 53 deletions
+73 -50
View File
@@ -133,26 +133,45 @@ class _FhycxPageState extends State<FhycxContentNew> {
} catch (e) {}
}
// 使用 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(() {});
},
);
},
);
}
@@ -754,44 +773,48 @@ class _FhycxPageState extends State<FhycxContentNew> {
),
)
: SizedBox.shrink(),
KeyboardAvoider(
autoScroll: true,
child: Container(
color: Color.fromRGBO(244, 244, 244, 1),
child: Column(
children: <Widget>[
//1、得到格林曼黑度标准和视频播放按钮组件
getHdAndPlay(),
//2、得到违章图片组件
imageWztp,
SizedBox(height: ScreenUtil().setHeight(_marginVer)),
//3、得到违章图片说明信息组件
getWztpSmxx(),
SizedBox(height: ScreenUtil().setHeight(_marginVer)),
//7、得到黑烟初审信息组件
getHyshInfo('hycsInfo'),
SizedBox(height: ScreenUtil().setHeight(_marginVer)),
//8、得到黑烟复审信息组件
getHyshInfo('hyfhInfo'),
SizedBox(height: ScreenUtil().setHeight(_marginVer)),
// //7、得到审核信息组件5:初审人员,初审时间
// getWzxxPart5(),
// //8、得到审核信息组件6:复审人员,复审时间
// getWzxxPart6(),
// SizedBox(height: 6),
// Divider(height: 1.0, color: Colors.blue),
// SizedBox(height: 6),
//6、得到推送交警状态信息组件7:推送状态
//getWzxxPart7(),
// SizedBox(height: 8),
// Divider(height: 1.0, color: Colors.blue),
SizedBox(height: 18),
//9、得到推送交警确认组件
getTsjjQr(),
SizedBox(height: 10),
],
ListView(
// physics: NeverScrollableScrollPhysics(), // 允许ListView滚动
// physics: null, // 允许ListView滚动
physics: scrollPhysics,
children: [
Container(
color: Color.fromRGBO(244, 244, 244, 1),
child: Column(
children: <Widget>[
//1、得到格林曼黑度标准和视频播放按钮组件
getHdAndPlay(),
//2、得到违章图片组件
imageWztp,
SizedBox(height: ScreenUtil().setHeight(_marginVer)),
//3、得到违章图片说明信息组件
getWztpSmxx(),
SizedBox(height: ScreenUtil().setHeight(_marginVer)),
//7、得到黑烟初审信息组件
getHyshInfo('hycsInfo'),
SizedBox(height: ScreenUtil().setHeight(_marginVer)),
//8、得到黑烟复审信息组件
getHyshInfo('hyfhInfo'),
SizedBox(height: ScreenUtil().setHeight(_marginVer)),
// //7、得到审核信息组件5:初审人员,初审时间
// getWzxxPart5(),
// //8、得到审核信息组件6:复审人员,复审时间
// getWzxxPart6(),
// SizedBox(height: 6),
// Divider(height: 1.0, color: Colors.blue),
// SizedBox(height: 6),
//6、得到推送交警状态信息组件7:推送状态
//getWzxxPart7(),
// SizedBox(height: 8),
// Divider(height: 1.0, color: Colors.blue),
SizedBox(height: 18),
//9、得到推送交警确认组件
getTsjjQr(),
SizedBox(height: 10),
],
),
),
),
],
),
Positioned(
//alignment: Alignment(0.9, 0.35),
+2 -3
View File
@@ -595,6 +595,8 @@ class _HyshPageState extends State<HyshContentNew> with SingleTickerProviderStat
// }
// 使用自定义 my_flutter_drag_scale 插件,完美解决Listview滚动与图片缩放拖动之间的手势冲突,不会消耗点击事件,滚动很灵敏
ScrollPhysics scrollPhysics;
bool bZoomedInit = true; // 图片是否为原样大小
Widget getNetworkImage(String url) {
return CachedNetworkImage(
imageUrl: url,
@@ -691,9 +693,6 @@ class _HyshPageState extends State<HyshContentNew> with SingleTickerProviderStat
double _marginVertical5 = 10;
double _marginVertical6 = 20;
ScrollPhysics scrollPhysics;
bool bZoomedInit = true; // 图片是否为原样大小
Future getTopTabsMap() async {
//map遍历,清空数据
topTabs_map.forEach((key, value) {