gpt4 book ai didi

flutter - 单击GestureDetector时如何突出显示颜色

转载 作者:行者123 更新时间:2023-12-03 03:21:53 25 4
gpt4 key购买 nike

我有一个GestureDetector作为以下代码:

GestureDetector(
onTapDown: _onTapDown,
onTapUp: _onTapUp,
child: Transform.scale(
scale: _scale,
child: _animatedButtonUI,
),
),

因此,我只想在单击时像 FlatButton一样突出颜色,因为它具有 highlightColor属性...

有没有办法做这样的事情...

这是 widget的相关 GestureDetector:
Widget get _animatedButtonUI => Container(
height: 50,
width: 320,
decoration: BoxDecoration(
border: Border.all(
color: Color(0xFF9EC33B),
),
borderRadius: BorderRadius.circular(100.0),
color: Colors.white,
),
child: Padding(
padding: const EdgeInsets.only(left: 64),
child: Row(
children: <Widget>[
Image.asset(
'assets/images/icggl.png',
width: 24,
),
Center(
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
'COTINUE WITH GOOGLE',
style: TextStyle(
fontSize: 13.0,
fontWeight: FontWeight.bold,
color: Color(0xFF9EC33B),
),
),
),
),
],
),
),
);

最佳答案

墨水池应如下所示:

InkWell(
onTap: () {},
highlightColor: Colors.red,
child: _Transform.scale(
scale: _scale,
child: _animatedButtonUI,
),
);

-编辑-

_animatedButtonUI的此修改版本应执行您想要的操作:
 Widget _animatedButtonUI (){
return Container(
height: 50,
width: 320,
decoration: BoxDecoration(
border: Border.all(
color: Color(0xFF9EC33B),
),
borderRadius: BorderRadius.circular(100.0),
color: Colors.white,
),
child: Material(
type: MaterialType.transparency,
child: InkWell(
onTap:(){},
highlightColor: Colors.red,
borderRadius: BorderRadius.circular(100.0),
child: Padding(
padding: const EdgeInsets.only(left: 64),
child: Row(
children: <Widget>[
Image.asset(
'assets/images/icggl.png',
width: 24,
),
Center(
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
'COTINUE WITH GOOGLE',
style: TextStyle(
fontSize: 13.0,
fontWeight: FontWeight.bold,
color: Color(0xFF9EC33B),
),
),
),
),
],
),
),
),
),
);
}

关于flutter - 单击GestureDetector时如何突出显示颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62289116/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com