当将img设置成可点击事件时,如何让其周边可点击,放大点击区域,需要包裹一层Container并且设置color,不设置color则还是img区域可点击,Container区域不能点击,如下代码:
GestureDetector(
child: Container(
height: ScreenUtil.getInstance().getWidth(80),
width: ScreenUtil.getInstance().getWidth(160),
alignment: Alignment.centerLeft,
child: isClick
? Image.asset(Utils.getImgPath("icon_navigation_back_press"))
: Image.asset(Utils.getImgPath("icon_navigation_back")),
padding: EdgeInsets.fromLTRB(
ScreenUtil.getInstance().getWidth(20),
ScreenUtil.getInstance().getWidth(10),
ScreenUtil.getInstance().getWidth(20),
ScreenUtil.getInstance().getWidth(10)),
color: MyColors.transparent,//此处记得要设置
),
onTap: () {
setState(() {
isClick = true;
});
Navigator.pop(context);
},
),