import 'package:flutter/material.dart'; import 'package:test_sa/animations/number_incremental_animation.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; class CustomBadge extends StatelessWidget { final Widget child; // The widget that the badge will be overlaid on. final int value; // The value or text to be displayed in the badge. final Color color; // The background color of the badge. const CustomBadge({ Key? key, required this.child, required this.value, this.color = AppColor.red30, // Default color is red }) : super(key: key); @override Widget build(BuildContext context) { return Stack( clipBehavior: Clip.none, // Allows the badge to overflow its container. children: [ child, // The main widget // if (value > 0) Positioned( right: -6, top: -6, child: Opacity( opacity: value > 0 ? 1 : 0, child: Container( height: 23, constraints: const BoxConstraints(minWidth: 23), padding: const EdgeInsets.all(3), alignment: Alignment.center, decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(30)), child: CounterAnimatedText( value: value, style: const TextStyle(color: AppColor.white10, fontFamily: 'Poppins', fontSize: 10, fontWeight: FontWeight.w700), ), ), ), ), ], ); } }