【问题标题】:flutter container remove outline border shadow颤振容器去除轮廓边框阴影
【发布时间】:2021-05-06 05:12:21
【问题描述】:

我想删除在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,
    ),
  ),
),

【问题讨论】:

    标签: flutter dart containers decoration


    【解决方案1】:

    我不确定这是否是 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,
      ),
    ),
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-04
      • 1970-01-01
      • 2011-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-17
      • 2021-10-25
      相关资源
      最近更新 更多