@@ -2,16 +2,17 @@ import 'package:flutter/widgets.dart';
22import 'package:flutter/material.dart' ;
33import 'package:ui_kit/shape/gf_avatar_shape.dart' ;
44import 'package:ui_kit/size/gf_size.dart' ;
5+ import 'package:ui_kit/colors/gf_color.dart' ;
56
67class GFAvatar extends StatelessWidget {
78 /// Typically a [Text] widget. If the [CircleAvatar] is to have an image, use [backgroundImage] instead.
89 final Widget child;
910
10- /// The color with which to fill the circle.
11- final Color backgroundColor;
11+ /// use [Color] or [GFColor] . The color with which to fill the circle.
12+ final dynamic backgroundColor;
1213
13- /// The default text color for text in the circle.
14- final Color foregroundColor;
14+ /// use [Color] or [GFColor] . The default text color for text in the circle.
15+ final dynamic foregroundColor;
1516
1617 /// The background image of the circle.
1718 final ImageProvider backgroundImage;
@@ -26,29 +27,19 @@ class GFAvatar extends StatelessWidget {
2627 final double maxRadius;
2728
2829 /// size of avatar like [double] or [GFSize] i.e, 1.2, small, medium, large etc.
29- final GFSize size;
30+ final dynamic size;
3031
31- /// shape of avatar [GFAvatarShape] i.e, standard, pills , square
32+ /// shape of avatar [GFAvatarShape] i.e, standard, circle , square
3233 final GFAvatarShape shape;
3334
3435 /// border radius to give extra radius for avatar square or standard shape
36+ /// Not applicable to circleshape
3537 final BorderRadius borderRadius;
3638
37- // The default radius if nothing is specified.
38- static const double _defaultRadius = 20.0 ;
39-
40- // The default radius if avater size GFSize.small selected.
41- static const double _smallRadius = 16.0 ;
42-
43- // The default radius if avater size GFSize.large selected.
44- static const double _largeRadius = 28.0 ;
45-
46- // The default min if only the max is specified.
47- static const double _defaultMinRadius = 0.0 ;
48-
49- // The default max if only the min is specified.
50- static const double _defaultMaxRadius = double .infinity;
39+ // /// The default max if only the min is specified.
40+ // static const double _defaultMaxRadius = double.infinity;
5141
42+ /// Create Avatar of all types i,e, square, circle, standard with different sizes.
5243 const GFAvatar (
5344 {Key key,
5445 this .child,
@@ -66,33 +57,17 @@ class GFAvatar extends StatelessWidget {
6657
6758 double get _minDiameter {
6859 if (radius == null && minRadius == null && maxRadius == null ) {
69- if (size == GFSize .medium) {
70- return _defaultRadius * 2.0 ;
71- } else if (size == GFSize .small) {
72- return _smallRadius * 2.0 ;
73- } else if (size == GFSize .large) {
74- return _largeRadius * 2.0 ;
75- } else {
76- return _defaultRadius * 2.0 ;
77- }
60+ return getGFSize (size);
7861 } else {
79- return 2.0 * (radius ?? minRadius ?? _defaultMinRadius );
62+ return 2.0 * (radius ?? minRadius ?? 0 );
8063 }
8164 }
8265
8366 double get _maxDiameter {
8467 if (radius == null && minRadius == null && maxRadius == null ) {
85- if (size == GFSize .medium) {
86- return _defaultRadius * 2.0 ;
87- } else if (size == GFSize .small) {
88- return _smallRadius * 2.0 ;
89- } else if (size == GFSize .large) {
90- return _largeRadius * 2.0 ;
91- } else {
92- return _defaultRadius * 2.0 ;
93- }
68+ return getGFSize (size);
9469 } else {
95- return 2.0 * (radius ?? maxRadius ?? _defaultMaxRadius );
70+ return 2.0 * (radius ?? maxRadius ?? 0 );
9671 }
9772 }
9873
@@ -110,6 +85,8 @@ class GFAvatar extends StatelessWidget {
11085
11186 @override
11287 Widget build (BuildContext context) {
88+ Color backgroundColor = getGFColor (this .backgroundColor);
89+ Color foregroundColor = getGFColor (this .foregroundColor);
11390 assert (debugCheckHasMediaQuery (context));
11491 final ThemeData theme = Theme .of (context);
11592 TextStyle textStyle =
0 commit comments