You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/new_views/common_widgets/custom_badge.dart

42 lines
1.3 KiB
Dart

import 'package:flutter/material.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: 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: Text(
value.toString(),
style: const TextStyle(color: AppColor.white10, fontFamily: 'Poppins', fontSize: 10, fontWeight: FontWeight.w700),
),
),
),
],
);
}
}