Unable to set transparent badge
aideric opened this issue · 6 comments
Environment
Package version: 3.0.2
Platform: Any
Device information: Any
Description
Expected behavior:
Can show transparent badge
Current behavior:
White badge
Steps to reproduce
- Download the example app
- Change the _shoppingCartBadge to the following
Widget _shoppingCartBadge() {
return badges.Badge(
position: badges.BadgePosition.topEnd(top: 0, end: 3),
badgeAnimation: badges.BadgeAnimation.slide(
// disappearanceFadeAnimationDuration: Duration(milliseconds: 200),
// curve: Curves.easeInCubic,
),
showBadge: _showCartBadge,
badgeStyle: badges.BadgeStyle(
badgeColor: Colors.transparent,
),
badgeContent: Text(
_cartBadgeAmount.toString(),
style: TextStyle(color: Colors.black),
),
child: IconButton(icon: Icon(Icons.shopping_cart), onPressed: () {}),
);
}
- build the app
Images
Fix
flutter_badges/lib/src/badge.dart
Lines 190 to 192 in d5db6fc
Material(
shape: border,
elevation: widget.badgeStyle.elevation,
type: MaterialType.transparency,
Using the MaterialType.transparency can set the Material widget to transparent background
I found that the new badge shapes, twitter and instagram allows transparency as per normal while square and circle do not.
Hello, this problem has been solved 5 weeks ago, can we have an update on when the next release is planned please as it is a regression ?
I just need the info to know if I must switch to make my own badges or if it coming soon
@yadaniyil Thx a lot, working perfectly
Hi, using type: MaterialType.transparency
opaques the elevation: widget.badgeStyle.elevation
which defaults to 2. Maybe BadgeStyle
could support a new property like allowTransparency
then:
type: widget.badgeStyle.allowTransparency ? MaterialType.transparency : MaterialType.canvas
.