[英]How to make a radial gradient floating action button
Set a container as the child of that FAB and assign a gradient to the container.将一个容器设置为该 FAB 的子级,并为该容器分配一个渐变。
FloatingActionButton(
onPressed: () {},
tooltip: 'Cool FAB',
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: RadialGradient(
center: const Alignment(0.0, 0.0),
radius: 0.5,
colors: [ Color(0xFF0187D0), Color(0xFF01579C),],
),
),
),
),
It will look like:它看起来像:
EDIT:编辑:
For adding icon, you have to specify a size to your container and set the icon as it's child (I've used the FAB default size of 56x56).要添加图标,您必须为容器指定大小并将图标设置为子图标(我使用 FAB 默认大小为 56x56)。
FloatingActionButton(
onPressed: () {},
tooltip: 'Cool FAB',
child: Container(
width: 56,
height: 56,
child: Icon(Icons.settings),
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: RadialGradient(
center: const Alignment(0.0, 0.0),
radius: 0.5,
colors: [ Color(0xFF0187D0), Color(0xFF01579C),],
),
),
),
),
And now it will look like:现在它看起来像:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.