@@ -11,28 +11,27 @@ class FlutterSwitch extends StatefulWidget {
1111 inactiveTextColor,
1212 toggleColor;
1313 final double width, height, toggleSize, valueFontSize, borderRadius, padding;
14- final Widget activeText;
15- final Widget offText;
14+ final String activeText, offText;
1615
17- const FlutterSwitch ({
18- Key key,
19- this .value,
20- this .onToggle,
21- this .activeColor = Colors .blue,
22- this .inactiveColor = Colors .grey,
23- this .activeTextColor = Colors .white70,
24- this .inactiveTextColor = Colors .white70,
25- this .toggleColor = Colors .white,
26- this .width = 70.0 ,
27- this .height = 35.0 ,
28- this .toggleSize = 25.0 ,
29- this .valueFontSize = 16.0 ,
30- this .borderRadius = 20.0 ,
31- this .padding = 4.0 ,
32- this .showOnOff = false ,
33- this .activeText,
34- this .offText
35- }) : super (key: key);
16+ const FlutterSwitch (
17+ { Key key,
18+ this .value,
19+ this .onToggle,
20+ this .activeColor = Colors .blue,
21+ this .inactiveColor = Colors .grey,
22+ this .activeTextColor = Colors .white70,
23+ this .inactiveTextColor = Colors .white70,
24+ this .toggleColor = Colors .white,
25+ this .width = 70.0 ,
26+ this .height = 35.0 ,
27+ this .toggleSize = 25.0 ,
28+ this .valueFontSize = 16.0 ,
29+ this .borderRadius = 20.0 ,
30+ this .padding = 4.0 ,
31+ this .showOnOff = false ,
32+ this .activeText,
33+ this .offText})
34+ : super (key: key);
3635
3736 @override
3837 _FlutterSwitchState createState () => _FlutterSwitchState ();
@@ -125,11 +124,9 @@ class _FlutterSwitchState extends State<FlutterSwitch>
125124
126125 Widget get _activeText {
127126 if (widget.showOnOff) {
128- if (widget? .activeText != null ) return widget.activeText;
129-
130127 return Text (
131- "On" ,
132- style: TextStyle (
128+ (widget ? .activeText != null ) ? widget.activeText : "On" ,
129+ style: TextStyle (
133130 color: widget.activeTextColor,
134131 fontWeight: FontWeight .w900,
135132 fontSize: widget.valueFontSize,
@@ -142,10 +139,8 @@ class _FlutterSwitchState extends State<FlutterSwitch>
142139
143140 Widget get _offText {
144141 if (widget.showOnOff) {
145- if (widget? .offText != null ) return widget.offText;
146-
147142 return Text (
148- "Off" ,
143+ (widget ? .offText != null ) ? widget.offText : "Off" ,
149144 style: TextStyle (
150145 color: widget.inactiveTextColor,
151146 fontWeight: FontWeight .w900,
0 commit comments