有人可以帮我解决这个问题吗?我刚开始使用 flutter,我开发这个应用程序已经有一段时间了,遇到了这个问题。不知道好像是什么问题
我还没有尝试任何东西,因为我不知道任何替代代码
Consumer<FavsProvider>(
builder: (_, favs, ch) => Badge(
badgeColor: ColorsConsts.cartBadgeColor,
animationType: BadgeAnimationType.slide,
toAnimate: true,
position: BadgePosition.topEnd(top: 5, end: 7),
badgeContent: Text(
favs.getFavsItems.length.toString(),
style: TextStyle(color: Colors.white),
),
如果你使用的是 badges flutter package 的最新版本。您需要将 BadgeStyle 定义为 badgeStyle 属性。检查这个并告诉我它是否解决了你的问题。
Badge(
position: badges.BadgePosition.topEnd(top: -10, end: -12),
showBadge: true,
ignorePointer: false,
onTap: () {},
badgeContent: // this enebles what you put inside badge such as numbers, icons etc...
Icon(Icons.check, color: Colors.white, size: 10),
badgeAnimation: badges.BadgeAnimation.rotation(
animationDuration: Duration(seconds: 1),
colorChangeAnimationDuration: Duration(seconds: 1),
loopAnimation: false,
curve: Curves.fastOutSlowIn,
colorChangeAnimationCurve: Curves.easeInCubic,
),
badgeStyle: BadgeStyle( // this provides you badge shape, color etc.
shape: badges.BadgeShape.square,
badgeColor: Colors.blue,
padding: EdgeInsets.all(5),
borderRadius: BorderRadius.circular(4),
borderSide: BorderSide(color: Colors.white, width: 2),
borderGradient: badges.BadgeGradient.linear(
colors: [Colors.red, Colors.black]),
badgeGradient: badges.BadgeGradient.linear(
colors: [Colors.blue, Colors.yellow],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
elevation: 0,
),
child:Container()
)