如何减少抖动中的边距或填充

时间:2020-05-16 08:11:22

标签: flutter flutter-layout

enter image description here

您好,我想知道是否有必要将边距或内边距设置得更接近iconUser,我想在iconUser顶部获得圆形,尝试过设置边距或内边距,但仍然无法解决此问题。

   children: <Widget>[
                    SizedBox(width: 10,),
                    GestureDetector(
                      onTap: (){},
                      child: Image.asset("assets/ic_user_center.png",height: 16.0,width: 16.0,)
                    )
                  ],
                ),
                Padding(
                  padding: const EdgeInsets.only(bottom: 8.0),
                  child: Container(
                    width: 5.0,
                    height: 5.0,
                    decoration: BoxDecoration(
                      shape: BoxShape.circle,
                      color: Colors.white
                    ),
                  ),
                )
              ],
            ),

2 个答案:

答案 0 :(得分:1)

您可以使用Stack和“已定位”来指定要放置该白点的位置

答案 1 :(得分:0)

enter image description here

@override
Widget build(BuildContext context) {
  var radius = 20.0;

  return Scaffold(
    body: Center(
      child: SizedBox.fromSize(
        size: Size.fromRadius(radius),
        child: Stack(
          fit: StackFit.expand,
          children: <Widget>[
            FittedBox(
              child: Icon(
                Icons.account_circle,
                color: Colors.red,
              ),
            ),
            Positioned(
              right: 0,
              child: Container(
                decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.black),
                width: radius / 2,
                height: radius / 2,
              ),
            )
          ],
        ),
      ),
    ),
  );
}

您也可以将PositionedAlign一起使用,而不是alignment: Alignment.topRight

相关问题