Skip to content

Commit

Permalink
fix: Unable to set transparent badge #100 (#102)
Browse files Browse the repository at this point in the history
* Fixes Unable to set transparent badge #100

* Update .gitignore
  • Loading branch information
yadaniyil authored Feb 16, 2023
1 parent d5db6fc commit b457c37
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ unlinked_spec.ds
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
example/.flutter-plugins-dependencies
4 changes: 3 additions & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -213,6 +213,7 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -249,6 +250,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions lib/src/badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class BadgeState extends State<Badge> with TickerProviderStateMixin {
: Material(
shape: border,
elevation: widget.badgeStyle.elevation,
// Without this Colors.transparent will be ignored
type: MaterialType.transparency,
child: AnimatedContainer(
curve: widget.badgeAnimation.colorChangeAnimationCurve,
duration: widget.badgeAnimation.toAnimate
Expand Down
12 changes: 12 additions & 0 deletions test/badges_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ void main() {
shape: badges.BadgeShape.square,
borderRadius: BorderRadius.circular(5),
padding: const EdgeInsets.all(2),
badgeColor: Colors.transparent,
badgeGradient: const badges.BadgeGradient.linear(
colors: [
Colors.blue,
Expand Down Expand Up @@ -392,6 +393,17 @@ void main() {
expect(find.text('MUSIC'), findsOneWidget);
});

testWidgets('Badge background color should match', (tester) async {
await tester.pumpWidget(_wrapWithMaterialApp(badge));

final badgeWidget =
tester.widget<badges.Badge>(find.byType(badges.Badge));
expect(
badgeWidget.badgeStyle.badgeColor,
Colors.transparent,
);
});

testWidgets('Badge gradient colors should match', (tester) async {
await tester.pumpWidget(_wrapWithMaterialApp(badge));

Expand Down

0 comments on commit b457c37

Please sign in to comment.