With latest version (1.1.4), using BadgeShape.square causes errors
montyr75 opened this issue · 1 comments
montyr75 commented
With 1.1.4 (not previous versions), this code crashes:
Badge(
badgeColor: color,
padding: const EdgeInsets.all(2.0),
shape: BadgeShape.square,
toAnimate: false,
badgeContent: Text(
tn.value.toString(),
style: style.copyWith(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
)
Console:
The following assertion was thrown building Badge(dirty, dependencies: [_EffectiveTickerMode], state: BadgeState#b7d97(ticker inactive)):
'package:flutter/src/painting/rounded_rectangle_border.dart': Failed assertion: line 36 pos 15: 'borderRadius != null': is not true.
The relevant error-causing widget was:
Badge file:///C:/Projects/www/Dart/_flutter/bt_buddy/lib/widgets/target_number_display.dart:40:11
When the exception was thrown, this was the stack:
#2 new RoundedRectangleBorder (package:flutter/src/painting/rounded_rectangle_border.dart:36:15)
#3 BadgeState._getBadge (package:badges/src/badge.dart:111:11)
#4 BadgeState.build (package:badges/src/badge.dart:81:14)
#5 StatefulElement.build (package:flutter/src/widgets/framework.dart:4792:27)
#6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:15)
If I comment out the shape
field, it works again, but it becomes circular...
yadaniyil commented
@montyr75 sorry for delay.
You can use following code:
Badge(
toAnimate: false,
badgeColor: Colors.red,
child: Icon(Icons.mail),
shape: BadgeShape.square,
padding: const EdgeInsets.all(2.0),
position: BadgePosition.topEnd(top: -12, end: -14),
badgeContent: Text('10', style: TextStyle(color: Colors.white)),
),
Perhaps you are using an older version of the plugin or Flutter.
Make sure that you have a plugin with the version badges: ^1.1.5
or higher.
Also check and update if you need Flutter to version 1.22.0
or higher.
These actions should help you.