[英]How to create radio button with image in Flutter
您可以尝试这种方法:
int _value = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Row(
children: <Widget>[
GestureDetector(
onTap: () => setState(() => _value = 0),
child: Container(
height: 56,
width: 56,
color: _value == 0 ? Colors.grey : Colors.transparent,
child: Icon(Icons.call),
),
),
SizedBox(width: 4),
GestureDetector(
onTap: () => setState(() => _value = 1),
child: Container(
height: 56,
width: 56,
color: _value == 1 ? Colors.grey : Colors.transparent,
child: Icon(Icons.message),
),
),
],
),
),
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.