首页 > 解决方案 > 有什么方法可以将颤振中的徽章对齐到最右边?

问题描述

当前输出的图片:

我使用的代码:

Badge(
                              badgeColor: CUSTOM_GREEN,
                              shape: BadgeShape.square,
                              borderRadius: 20,
                              toAnimate: false,
                              badgeContent: Text("Responded",
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 12)),
                            )

有什么办法可以将徽章对齐到最右边吗?

标签: flutterbadge

解决方案


将 MainAxisAlignment.spaceBetween 与 Row 小部件一起使用。

 Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Row(children: <Widget>[
                  CircleAvatar(),
                  Column(
                    children: [],
                  )
                ]),
                Badge(
                  badgeColor: CUSTOM_GREEN,
                  shape: BadgeShape.square,
                  borderRadius: 20,
                  toAnimate: false,
                  badgeContent: Text("Responded",
                      style: TextStyle(color: Colors.white, fontSize: 12)),
                )
              ]),

推荐阅读