@@ -19,7 +19,9 @@ class GFToggle extends StatefulWidget {
1919 this .disabledTrackColor,
2020 this .disabledThumbColor,
2121 this .type,
22- this .boxShape
22+ this .boxShape,
23+ this .borderRadius
24+
2325
2426
2527 }) : super (key: key);
@@ -35,6 +37,7 @@ class GFToggle extends StatefulWidget {
3537 final Color disabledThumbColor;
3638 final Color disabledTrackColor;
3739 final BoxShape boxShape;
40+ final BorderRadius borderRadius;
3841
3942
4043
@@ -101,7 +104,6 @@ class _GFToggleState extends State<GFToggle> with TickerProviderStateMixin{
101104 setState (() {
102105 isOn = ! isOn;
103106 });
104- print (controller.status);
105107 switch (controller.status) {
106108 case AnimationStatus .dismissed:
107109 controller.forward ();
@@ -111,6 +113,7 @@ class _GFToggleState extends State<GFToggle> with TickerProviderStateMixin{
111113 break ;
112114 default :
113115 }
116+ widget.onChanged (isOn);
114117
115118 },
116119 child: Stack (
@@ -128,15 +131,15 @@ class _GFToggleState extends State<GFToggle> with TickerProviderStateMixin{
128131 height: widget.type == GFToggleType .ios ? 25 : 15 ,
129132 decoration: BoxDecoration (
130133 color: isOn ? widget.enabledTrackColor?? Colors .lightGreen: widget.disabledTrackColor ?? Colors .grey,
131- borderRadius: BorderRadius .all (Radius .circular (20 ))
134+ borderRadius: widget.type == GFToggleType .square ? BorderRadius . all ( Radius . circular ( 0 )) : widget.borderRadius ?? BorderRadius .all (Radius .circular (20 ))
132135
133136 ),
134137 child:
135138 Padding (padding: EdgeInsets .only (left: 3 , right: 3 , top: 3.4 ), child:
136139 isOn?
137140
138- widget.type == GFToggleType .android || widget.type == GFToggleType .ios ? Container () : Text ( widget.enabledText ?? 'ON' ,style: widget.enabledTextColor?? TextStyle (color: Colors .white, fontSize: 8 ),):
139- widget.type == GFToggleType .android || widget.type == GFToggleType .ios ? Container () : Text (widget.disabledText ?? 'OFF' , textAlign: TextAlign .end, style: widget.disabledTextColor?? TextStyle (color: Colors .white, fontSize: 8 ),))
141+ Text ( widget.enabledText ?? widget.type== GFToggleType .custom ? 'ON' : ' ' ,style: widget.enabledTextColor?? TextStyle (color: Colors .white, fontSize: 8 ),):
142+ Text ( widget.disabledText ?? widget.type== GFToggleType .custom ? 'OFF' : ' ' , textAlign: TextAlign .end, style: widget.disabledTextColor?? TextStyle (color: Colors .white, fontSize: 8 ),))
140143
141144 ),
142145 ),
@@ -157,6 +160,7 @@ class _GFToggleState extends State<GFToggle> with TickerProviderStateMixin{
157160 break ;
158161 default :
159162 }
163+ widget.onChanged (isOn);
160164 },
161165 child: SlideTransition (
162166 position: offset,
@@ -165,7 +169,7 @@ class _GFToggleState extends State<GFToggle> with TickerProviderStateMixin{
165169 height: 20 ,
166170 width: 20 ,
167171 decoration: BoxDecoration (
168- shape: widget.boxShape ?? BoxShape .circle,
172+ shape: widget.type == GFToggleType .square ? BoxShape .rectangle : widget. boxShape ?? BoxShape .circle,
169173 color: widget.enabledThumbColor ?? Colors .white,
170174 boxShadow: [
171175 new BoxShadow (
0 commit comments