Created
July 15, 2019 07:38
-
-
Save flutter-devs/9b235f7597f595c91b41953574cefa30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return AnimatedBuilder( | |
animation: _animationController, | |
builder: (context, child) { | |
return Container( | |
width: 70.0, | |
height: 35.0, | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.circular(20.0), | |
color: _circleAnimation.value == Alignment.centerLeft | |
? Colors.grey | |
: widget.activeColor), | |
child: Padding( | |
padding: const EdgeInsets.only( | |
top: 4.0, bottom: 4.0, right: 4.0, left: 4.0), | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
_circleAnimation.value == Alignment.centerRight | |
? Padding( | |
padding: const EdgeInsets.only(left: 4.0, right: 4.0), | |
child: Text( | |
'On', | |
style: TextStyle( | |
color: Colors.white70, | |
fontWeight: FontWeight.w900, | |
fontSize: 16.0), | |
), | |
) | |
: Container(), | |
Align( | |
alignment: _circleAnimation.value, | |
child: Container( | |
width: 25.0, | |
height: 25.0, | |
decoration: BoxDecoration( | |
shape: BoxShape.circle, color: Colors.white), | |
), | |
), | |
_circleAnimation.value == Alignment.centerLeft | |
? Padding( | |
padding: const EdgeInsets.only(left: 4.0, right: 5.0), | |
child: Text( | |
'Off', | |
style: TextStyle( | |
color: Colors.white70, | |
fontWeight: FontWeight.w900, | |
fontSize: 16.0), | |
), | |
) | |
: Container(), | |
], | |
), | |
), | |
); | |
}, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment