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