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.
45 lines
1.3 KiB
Dart
45 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 String 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
|
|
Positioned(
|
|
right: -6,
|
|
top: -6,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(6),
|
|
decoration: BoxDecoration(
|
|
color: color,
|
|
shape: BoxShape.circle, // Makes the badge circular
|
|
),
|
|
child: Text(
|
|
value,
|
|
style: const TextStyle(
|
|
color: AppColor.white10,
|
|
fontFamily: 'Poppins',
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
} |