gpt4 book ai didi

flutter - 使容器可点击

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

我想让整行都可以点击,但只有点击 TextIcon 时打印才会显示。

 Padding(
padding: EdgeInsets.only(top: 15.0, left: 10.0, right: 10.0),
child: Container(
width: double.infinity,
padding: EdgeInsets.only(top: 15.0, bottom: 15.0),
decoration: BoxDecoration(
border: Border.all(width: 0.5),
borderRadius: BorderRadius.all(Radius.circular(15.0))),
child: GestureDetector(
onTap: () {
print('click');
},
child: Row(
children: <Widget>[
Padding(
child: Text(
Localization.of(context).location,
style: TextStyle(fontSize: 18),
),
padding: EdgeInsets.only(left: 10.0),
),
Spacer(),
Padding(
child: Container(
child: Icon(Icons.locations),
height: 25.0,
),
padding: EdgeInsets.only(right: 15.0),
)
],
),
)))

最佳答案

@John Joe,我认为使容器可点击的最简单方法是使用 InkWell 作为,

InkWell(
child: Container(
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
border: Border.all(width: 1.0, color: Colors.grey),
borderRadius: BorderRadius.all(Radius.circular(5.0))
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Locations', style: TextStyle(color: Colors.grey)),
Icon(Icons.edit_location, color: Colors.grey)
])),
onTap: () {
setState(() {
text = 'Locations Tapped!';
});
},
)

enter image description here

关于flutter - 使容器可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59034998/

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