part of ansu_ui; class ASRadioButton extends StatefulWidget { /// 选中的值 final T groupValue; ///按钮标题 final String title; /// 该按钮的值 final T value; ///按钮回调 final Function(T value) onTap; ASRadioButton({ Key key, this.groupValue, this.title, this.value, this.onTap, }) : super(key: key); @override _ASRadioButtonState createState() => _ASRadioButtonState(); } class _ASRadioButtonState extends State { bool get _selected => widget.value == widget.groupValue; @override Widget build(BuildContext context) { return InkWell( onTap: () => widget.onTap(widget.value), borderRadius: 13.radius, child: AnimatedContainer( padding: EdgeInsets.symmetric( horizontal: _selected ? 17.w : 16.w, vertical: _selected ? 5.w : 4.w, ), child: AnimatedDefaultTextStyle( child: Text(widget.title), style: TextStyle( color: _selected ? kLightTextColor : kTextSubColor, ), duration: Duration(milliseconds: 300), ), duration: Duration(milliseconds: 300), decoration: BoxDecoration( color: _selected ? kPrimaryColor : Colors.transparent, borderRadius: 13.radius, border: _selected ? null : Border.all( width: 1.w, color: Color(0xFF979797), ), ), ), ); } }