Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update _button.dart #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions lib/src/widgets/buttons/_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,19 @@ class NeuButtonState extends State<NeuButton>

@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
var doOnPressedAction = () => {
if (widget.onPressed != null) {widget.onPressed!()}
};

if (widget.enableAnimation) {
// do the on pressed action after the
// first part of animation
_controller.forward().then((value) {
doOnPressedAction();
_controller.reverse();
});
} else {
// do on pressed action without any
// animation
doOnPressedAction();
}
return GestureDetector(
// first part of animation
onTapDown: (details) {
_controller.forward();
},
// second part of animation and perform action
onTapUp: (details) {
_controller.reverse();
widget.onPressed!();
},
// end animation if user cancel the tap
onTapCancel: () {
_controller.reverse();
},
child: AnimatedBuilder(
animation: _animation,
Expand Down