Created
April 17, 2019 14:40
-
-
Save felixblaschke/c3d66d1f056fe6c1c93022f5c630f608 to your computer and use it in GitHub Desktop.
Switchlike Checkbox (Part 1)
This file contains hidden or 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
class SwitchlikeCheckbox extends StatelessWidget { | |
final bool checked; | |
SwitchlikeCheckbox({this.checked}); | |
@override | |
Widget build(BuildContext context) { | |
var tween = MultiTrackTween([ | |
Track("paddingLeft") | |
.add(Duration(milliseconds: 1000), Tween(begin: 0.0, end: 20.0)), | |
Track("color").add(Duration(milliseconds: 1000), | |
ColorTween(begin: Colors.grey, end: Colors.blue)), | |
Track("text") | |
.add(Duration(milliseconds: 500), ConstantTween("OFF")) | |
.add(Duration(milliseconds: 500), ConstantTween("ON")), | |
Track("rotation") | |
.add(Duration(milliseconds: 1000), Tween(begin: -2 * pi, end: 0.0)) | |
]); | |
return ControlledAnimation( | |
playback: checked ? Playback.PLAY_FORWARD : Playback.PLAY_REVERSE, | |
startPosition: checked ? 1.0 : 0.0, | |
duration: tween.duration * 1.2, | |
tween: tween, | |
curve: Curves.easeInOut, | |
builder: _buildCheckbox, | |
); | |
} | |
Widget _buildCheckbox(context, animation) { | |
// TODO: implement me | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment