Flutter按下变色的图标按钮

TextButton(
  child: Padding(
    padding: EdgeInsets.only(left: 20, right: 20),
    child: Text.rich(
      TextSpan(style: TextStyle(color: Colors.black54, fontSize: 13), children: [
        WidgetSpan(
          child: Icon(
            Icons.arrow_back_ios,
            //color: Colors.white,
          ),
          alignment: PlaceholderAlignment.middle,
        ),
      ]),
    ),
  ),
  style: ButtonStyle(
    foregroundColor: MaterialStateProperty.resolveWith((states) {
      return states.contains(MaterialState.pressed) ? Color(0xAAFFFFFF) : Colors.white;
    }),
    overlayColor: MaterialStateProperty.all(Colors.transparent),
    visualDensity: VisualDensity.compact,
    minimumSize: MaterialStateProperty.all(Size(50, 47)),
  ),
  onPressed: () {
    ToastUtil.toast('aaaaa');
  },
),

おすすめ

転載: blog.csdn.net/gaoyp/article/details/120527131