Skip to content

Instantly share code, notes, and snippets.

@PreyeaRegmi
Created June 15, 2021 08:58
Show Gist options
  • Save PreyeaRegmi/cab848cb9cdfd1f24d4cab5acdd9bb10 to your computer and use it in GitHub Desktop.
Save PreyeaRegmi/cab848cb9cdfd1f24d4cab5acdd9bb10 to your computer and use it in GitHub Desktop.
Intial bouncing effect added to the widget
//Animation Controller for setting bounce animation for "Swipe up" text widget
_swipeUpBounceAnimationController =
AnimationController(duration: Duration(milliseconds: 800), vsync: this)
..repeat(reverse: true);
//Animation for actual bounce effect
_swipeUpBounceAnimation = Tween<double>(begin: 0, end: -20).animate(
CurvedAnimation(
parent: _swipeUpBounceAnimationController,
curve: Curves.easeOutBack))
..addListener(() {
setState(() {
_swipeUpDy = _swipeUpBounceAnimation.value;
});
});
//We want to loop bounce effect until user intercepts with drag touch event.
_swipeUpBounceAnimationController.repeat(reverse: true);
//Animated value used by corresponding "Swipe up to Start" Widget in _getInitScreenWidgets() method
Positioned(
right: 0,
left: 0,
bottom: widget.height * .05,
child: Transform.translate(
offset: Offset(0, _swipeUpDy),
child: IgnorePointer(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.upload_rounded,
color: Colors.deepPurple,
size: 52,
),
Text(
"Swipe up to start",
style: TextStyle(color: Colors.grey.shade800),
)
]),
))),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment