【发布时间】:2021-10-04 17:35:04
【问题描述】:
我有一个按钮,需要将图标放置在矩形之外。
我可以用 Stack 很好地做到这一点,但是按钮边框与图标重叠,如您在此处看到的:
这是我的代码:
OutlinedButton(
style: scansButtonStyle,
onPressed: () {}, // TODO: add later
child: Stack(clipBehavior: Clip.none, children: [
Padding(
padding: const EdgeInsets.only(left: 50.0),
child: Text('CONNECT'),
),
Positioned(
bottom: 0,
left: -20,
child: CircleAvatar(
radius: 30,
backgroundColor: Colors.black,
child: CircleAvatar(
radius: 27,
backgroundColor: Colors.white,
child: Icon(
Icons.bluetooth_connected,
color: Colors.black,
size: 48,
),
),
),
),
]),
),
和样式:
final ButtonStyle scansButtonStyle = OutlinedButton.styleFrom(
alignment: Alignment.centerLeft,
primary: Colors.black,
backgroundColor: Color(0xfffcd722),
minimumSize: Size(242, 48),
padding: EdgeInsets.fromLTRB(20, 3, 20, 3),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.zero,
bottomRight: Radius.circular(16),
bottomLeft: Radius.zero),
),
textStyle: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.w600,
fontSize: 34,
fontFamily: 'HP',
),
side: BorderSide(
color: Colors.black,
width: 3.0,
style: BorderStyle.solid,
));
【问题讨论】:
-
可以分享你期待的图片吗?
-
我对其进行了编辑以包含预期的图像
标签: flutter button stack overlap