@@ -3,14 +3,14 @@ library flutter_switch;
33import 'package:flutter/material.dart' ;
44
55class FlutterSwitch extends StatefulWidget {
6- final bool value;
6+ final bool value, showOnOff ;
77 final ValueChanged <bool > onToggle;
8- final Color activeColor;
9- final Color inactiveColor;
10- final Color activeTextColor;
11- final Color inactiveTextColor;
8+ final Color activeColor,
9+ inactiveColor,
10+ activeTextColor,
11+ inactiveTextColor,
12+ toggleColor;
1213 final double width, height, toggleSize, valueFontSize, borderRadius, padding;
13- final bool showOnOff;
1414
1515 const FlutterSwitch ({
1616 Key key,
@@ -20,6 +20,7 @@ class FlutterSwitch extends StatefulWidget {
2020 this .inactiveColor = Colors .grey,
2121 this .activeTextColor = Colors .white70,
2222 this .inactiveTextColor = Colors .white70,
23+ this .toggleColor = Colors .white,
2324 this .width = 70.0 ,
2425 this .height = 35.0 ,
2526 this .toggleSize = 25.0 ,
@@ -35,7 +36,7 @@ class FlutterSwitch extends StatefulWidget {
3536
3637class _FlutterSwitchState extends State <FlutterSwitch >
3738 with SingleTickerProviderStateMixin {
38- Animation _circleAnimation ;
39+ Animation _toggleAnimation ;
3940 AnimationController _animationController;
4041
4142 @override
@@ -45,7 +46,7 @@ class _FlutterSwitchState extends State<FlutterSwitch>
4546 vsync: this ,
4647 duration: Duration (milliseconds: 60 ),
4748 );
48- _circleAnimation = AlignmentTween (
49+ _toggleAnimation = AlignmentTween (
4950 begin: widget.value ? Alignment .centerRight : Alignment .centerLeft,
5051 end: widget.value ? Alignment .centerLeft : Alignment .centerRight,
5152 ).animate (
@@ -75,14 +76,14 @@ class _FlutterSwitchState extends State<FlutterSwitch>
7576 padding: EdgeInsets .all (widget.padding),
7677 decoration: BoxDecoration (
7778 borderRadius: BorderRadius .circular (widget.borderRadius),
78- color: _circleAnimation .value == Alignment .centerLeft
79+ color: _toggleAnimation .value == Alignment .centerLeft
7980 ? widget.inactiveColor
8081 : widget.activeColor,
8182 ),
8283 child: Row (
8384 mainAxisAlignment: MainAxisAlignment .spaceBetween,
8485 children: < Widget > [
85- _circleAnimation .value == Alignment .centerRight
86+ _toggleAnimation .value == Alignment .centerRight
8687 ? Expanded (
8788 child: Container (
8889 padding: EdgeInsets .symmetric (horizontal: 4.0 ),
@@ -98,17 +99,17 @@ class _FlutterSwitchState extends State<FlutterSwitch>
9899 )
99100 : Container (),
100101 Align (
101- alignment: _circleAnimation .value,
102+ alignment: _toggleAnimation .value,
102103 child: Container (
103104 width: widget.toggleSize,
104105 height: widget.toggleSize,
105106 decoration: BoxDecoration (
106107 shape: BoxShape .circle,
107- color: Colors .white ,
108+ color: widget.toggleColor ,
108109 ),
109110 ),
110111 ),
111- _circleAnimation .value == Alignment .centerLeft
112+ _toggleAnimation .value == Alignment .centerLeft
112113 ? Expanded (
113114 child: Container (
114115 padding: EdgeInsets .symmetric (horizontal: 4.0 ),
0 commit comments