我正在自己学习颤振,我想制作一个可以使用的图示,url_launcher
但我不知道该怎么做。当我使用图示时,onTap
不起作用。我该如何解决这个问题?
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
Icon(
Icons.facebook_outlined,
size: 80,
color: Colors.black,
)
],
),
uj5u.com热心网友回复:
您可以使用 Gesturedecture 或 IconButton
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap:(){
launchUrl();
}
child:Icon(
Icons.facebook_outlined,
size: 80,
color: Colors.black,
)
)
],
)
图示按钮
IconButton(
icon: Icon(
Icons.facebook_outlined,
size: 80,
color: Colors.black,
),
onPressed:(){
launchUrl();
}
)
uj5u.com热心网友回复:
InkWell
提供onTap
,你可以Icon
用它包裹,我更喜欢飞溅效果。此外,您可以IconButton
像@Afridi Kaya 评论的那样使用。
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
InkWell(
onTap: () {
print("tapped InkWell");
/// todo: your launch
},
customBorder: const CircleBorder(),
child: const Icon(
Icons.facebook_outlined,
size: 80,
color: Colors.black,
),
),
IconButton(
onPressed: () {
/// todo: your launch
print("tapped IconButton");
},
iconSize: 80,
padding: EdgeInsets.zero,
alignment: Alignment.center,
icon: const Icon(
Icons.facebook_outlined,
color: Colors.black,
),
)
uj5u.com热心网友回复:
您可以使用IconButton
:
Center(
child: IconButton(
icon: Icon(Icons.facebook_outlined),
onPressed: () {
setState(() {
_isBluetoothOn = !_isBluetoothOn;
});
},
),
),
0 评论