0

我想删除这条彩色像素线,IconButton 我认为这条像素线与阴影无关

在此处输入图像描述

我的代码是:

Container(
    boxShadow: [
      BoxShadow(
        color: Colors.transparent,
      ),
    ],
    color: Colors.black,
    shape: BoxShape.circle,
    border: Border.all(
      color: Colors.white,
      width: 5,
    ),
  ),
  child: IconButton(
    color: Colors.white,
    icon: Icon(
       Icons.search,
    ),
  ),
),
4

1 回答 1

0

我不确定这是否是 Flutter 中的错误。您可以尝试添加另一种颜色Container作为其子项。

样本:

class CircleIconButton extends StatelessWidget {
  const CircleIconButton({
    required this.onPressed,
    this.border,
    this.color = Colors.black,
    this.icon = Icons.search,
    this.iconColor = Colors.white,
    Key? key,
  }) : super(key: key);

  final VoidCallback onPressed;
  final BoxBorder? border;
  final Color color;
  final IconData icon;
  final Color iconColor;

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        shape: BoxShape.circle,
        border: border,
      ),
      child: Container(
        decoration: BoxDecoration(
          color: color,
          shape: BoxShape.circle,
        ),
        child: IconButton(
          onPressed: onPressed,
          color: Colors.white,
          icon: Icon(icon),
        ),
      ),
    );
  }
}

用法:

CircleIconButton(
  onPressed: () {},
  border: Border.all(
    color: Colors.yellow,
    width: 5,
  ),
),
于 2021-05-06T05:52:06.667 回答