@@ -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,38 @@ 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
32+
33+
2834class _GFIconBadgeState extends State <GFIconBadge > {
2935 @override
3036 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- );
37+ padding: widget.padding,
38+ child: Stack (
39+ fit: StackFit .loose,
40+ alignment: Alignment .center,
41+ clipBehavior: Clip .none,
42+ children: [
43+ widget.child,
44+ widget.position == null
45+ ? PositionedDirectional (
46+ top: GFBadgePosition .topEnd ().top,
47+ end: GFBadgePosition .topEnd ().end,
48+ child: widget.counterChild,
49+ )
50+ : PositionedDirectional (
51+ top: widget.position! .top,
52+ end: widget.position! .end,
53+ bottom: widget.position! .bottom,
54+ start: widget.position! .start,
55+ child: widget.counterChild,
56+ )
57+ ],
58+ ));
4159}
0 commit comments