Skip to content

Commit 432a6f7

Browse files
committed
custom loader done
1 parent 7186082 commit 432a6f7

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

lib/components/loader/gf_loader.dart

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class GFLoader extends StatefulWidget {
1313
this.loaderColorThree = Colors.blueAccent,
1414
this.duration = const Duration(milliseconds: 1000),
1515
this.type = GFLoaderType.android,
16-
this.loaderIconOne = const Icon(Icons.blur_on),
17-
this.loaderIconTwo,
18-
this.loaderIconThree,
16+
this.loaderIconOne ,
17+
this.loaderIconTwo ,
18+
this.loaderIconThree ,
1919
// this.loaderSizeOne,
2020
// this.loaderSizeTwo,
2121
// this.loaderSizeThree,
2222
this.androidLoaderColor,
23-
this.loaderSize = 15.0,
23+
// this.loaderSize = 15.0,
2424
this.loaderstrokeWidth= 4.0,
2525
this.size = GFSize.medium,
2626
this.child
@@ -42,7 +42,7 @@ class GFLoader extends StatefulWidget {
4242
final Widget loaderIconTwo;
4343
final Widget loaderIconThree;
4444
final Animation<Color> androidLoaderColor;
45-
final dynamic loaderSize;
45+
// final dynamic loaderSize;
4646
final double loaderstrokeWidth;
4747
final dynamic size;
4848
final Widget child;
@@ -109,7 +109,12 @@ class _GFLoaderState extends State<GFLoader>
109109

110110
@override
111111
Widget build(BuildContext context) => Container(
112-
child: widget.type==GFLoaderType.android? Center(
112+
child: widget.child !=null? Loader(
113+
radius:GFSizesClass.getGFSize(widget.size)*0.3,
114+
type: widget.type,
115+
child: widget.child,
116+
117+
):widget.type==GFLoaderType.android? Center(
113118
child:Container(
114119
height: GFSizesClass.getGFSize(widget.size)* 0.7,
115120
width: GFSizesClass.getGFSize(widget.size)* 0.7,
@@ -124,13 +129,6 @@ class _GFLoaderState extends State<GFLoader>
124129
radius: GFSizesClass.getGFSize(widget.size)* 0.4
125130

126131
),
127-
):widget.type==GFLoaderType.custom?
128-
Container(
129-
// color: Colors.amber,
130-
// height: GFSizesClass.getGFSize(widget.size)* 10,
131-
// width: GFSizesClass.getGFSize(widget.size)* 10,
132-
child: widget.child,
133-
134132
):Row(
135133
mainAxisAlignment: MainAxisAlignment.center,
136134
children: <Widget>[
@@ -148,6 +146,7 @@ class _GFLoaderState extends State<GFLoader>
148146
color: widget.loaderColorOne,
149147
type: widget.type,
150148
icon: widget.loaderIconOne,
149+
child: widget.child,
151150
),
152151
),
153152
),
@@ -164,6 +163,7 @@ class _GFLoaderState extends State<GFLoader>
164163
color: widget.loaderColorTwo,
165164
type: widget.type,
166165
icon: widget.loaderIconTwo,
166+
//
167167
),
168168
),
169169
),
@@ -179,8 +179,9 @@ class _GFLoaderState extends State<GFLoader>
179179
radius: GFSizesClass.getGFSize(widget.size)*0.3,
180180
color: widget.loaderColorThree,
181181
type: widget.type,
182-
icon: widget.loaderIconThree
183-
,
182+
icon: widget.loaderIconThree,
183+
//
184+
184185
),
185186
),
186187
),
@@ -196,25 +197,31 @@ class _GFLoaderState extends State<GFLoader>
196197
}
197198

198199
class Loader extends StatelessWidget {
199-
const Loader({Key key, this.radius, this.color, this.type, this.icon})
200+
const Loader({Key key, this.radius, this.color, this.type, this.icon, this.size, this.child})
200201
: super(key: key);
201202

202203
final double radius;
203204
final Color color;
204205
final GFLoaderType type;
205-
final Icon icon;
206+
final Widget icon;
207+
final dynamic size;
208+
final Widget child;
206209

207210

208211
@override
209212
Widget build(BuildContext context) => Center(
210-
child:Container(
211-
width: radius,
212-
height: radius,
213-
decoration: BoxDecoration(
214-
color: color,
215-
shape: type == GFLoaderType.circle
216-
? BoxShape.circle
217-
: BoxShape.rectangle),
218-
)
213+
child:type== GFLoaderType.custom? Container(
214+
child: child!=null ?child:icon??Container())
215+
:Container(
216+
width: radius,
217+
height: radius,
218+
decoration: BoxDecoration(
219+
color: color,
220+
shape: type == GFLoaderType.circle
221+
? BoxShape.circle
222+
: BoxShape.rectangle),
223+
)
224+
219225
);
220226
}
227+

0 commit comments

Comments
 (0)