@@ -3,12 +3,13 @@ import 'package:getwidget/getwidget.dart';
33
44class GFIconBadge extends StatefulWidget {
55 /// Create badges of all types, check out [GFBadge] for button badges and [GFIconBadge] for icon badges.
6- const GFIconBadge ({
7- Key ? key,
8- this .padding = const EdgeInsets .symmetric (horizontal: 8 ),
9- required this .child,
10- required this .counterChild,
11- }) : super (key: key);
6+ const GFIconBadge (
7+ {Key ? key,
8+ this .padding = const EdgeInsets .symmetric (horizontal: 8 ),
9+ required this .child,
10+ required this .counterChild,
11+ this .position})
12+ : super (key: key);
1213
1314 /// child of type [Widget] is used to show icon.
1415 /// Use [GFIconButton] widget for compatibility.
@@ -21,21 +22,36 @@ class GFIconBadge extends StatefulWidget {
2122 /// The internal padding for the badge's [child] .
2223 final EdgeInsetsGeometry padding;
2324
25+ /// defines the position of [GFBadge] .
26+ final GFBadgePosition ? position;
27+
2428 @override
2529 _GFIconBadgeState createState () => _GFIconBadgeState ();
2630}
2731
2832class _GFIconBadgeState extends State <GFIconBadge > {
2933 @override
3034 Widget build (BuildContext context) => Container (
31- padding: widget.padding,
32- child: Stack (
33- children: < Widget > [
34- widget.child,
35- Positioned (
36- child: widget.counterChild,
37- ),
38- ],
39- ),
40- );
35+ padding: widget.padding,
36+ child: Stack (
37+ fit: StackFit .loose,
38+ alignment: Alignment .center,
39+ clipBehavior: Clip .none,
40+ children: [
41+ widget.child,
42+ widget.position == null
43+ ? PositionedDirectional (
44+ top: GFBadgePosition .topEnd ().top,
45+ end: GFBadgePosition .topEnd ().end,
46+ child: widget.counterChild,
47+ )
48+ : PositionedDirectional (
49+ top: widget.position! .top,
50+ end: widget.position! .end,
51+ bottom: widget.position! .bottom,
52+ start: widget.position! .start,
53+ child: widget.counterChild,
54+ )
55+ ],
56+ ));
4157}
0 commit comments