目标:在孩童时期实现具有可见半径和图像的完美大小的圆形按钮
截图演示:
从上图可以看出,我尝试了社区在这里提到的许多解决方案here
包含:
CircleAvatar(
child: Image.asset('assets/images/gucci.jpg')
)
ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.asset(
'assets/images/gucci.jpg',
height: 100.0,
width: 100.0,
)
)
Material(
elevation: 1.0,
shape: CircleBorder(),
clipBehavior: Clip.hardEdge,
color: Colors.transparent,
child: Ink.image(
image: AssetImage('assets/images/gucci.jpg'),
fit: BoxFit.cover,
width: 120.0,
height: 120.0,
child: InkWell(
onTap: () {},
)
)
)
关于如何实现这个设计的任何想法?
最佳答案
有很多选择供您选择。其中之一是“FloatingActionButton”。
SizedBox(
width: 60,
height: 60,
child: FittedBox(
fit: BoxFit.contain,
child: FloatingActionButton(
onPressed: () {},
shape: CircleBorder(
side: BorderSide(
color: Colors.black,
width: 1,
),
),
backgroundColor: Colors.white,
child: Padding(
padding: EdgeInsets.all(5),
child: Image.asset('assets/images/gucci.jpg'),
),
),
),
)
我更喜欢它
Container
因为按钮的所有属性,如 onPressed
或点击动画已在 FloatingActionButton
中实现并且您不需要使用 GestureDetector
或 InkWell
.您也可以使用
CircleBorder
在任何其他 Button
s 或 Widget
s 接受 ShapeBorder
.
关于user-interface - 具有可见半径和图像作为子项的圆形按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61426391/