Skip to content

Instantly share code, notes, and snippets.

@flutter-devs
Created July 15, 2019 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flutter-devs/9b235f7597f595c91b41953574cefa30 to your computer and use it in GitHub Desktop.
Save flutter-devs/9b235f7597f595c91b41953574cefa30 to your computer and use it in GitHub Desktop.
@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