flutter 未定义命名参数“badgeColor”

sh7euo9m  于 2023-05-08  发布在  Flutter
关注(0)|答案(1)|浏览(163)

有人能帮我一下吗。我只是新的使用Flutter,我一直在开发这个应用程序的一段时间,遇到了这个问题。我不知道是什么问题the errors of the code
我还没有尝试过任何东西,因为我不知道任何替代代码

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),
                  ),
hi3rlvi2

hi3rlvi21#

如果你使用的是badges flutter软件包的最新版本。您需要定义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()
)

相关问题