Closed nareddyt closed 4 years ago
Hey @nareddyt thanks for this Feature Request. It has been added and been released in version 0.0.4. You can check it here https://pub.dev/packages/animate_icons/versions/0.0.4
Both the onStartIconPress
and onEndIconPress
functions need to return a bool value
.
You can use AnimateIconController
to do that. Initialize the controller and pass it to the widget like this :
AnimateIconController controller = AnimateIconController();
AnimateIcons(
controller: controller,
.
.
.
)
controller.animateToStart() // will animate to endIcon without calling onEndIconPress
controller.animateToEnd() // will animate to endIcon without calling onStartIconPress
controller.isStart() // returns true if the current visible icon is the startIcon else false
controller.isEnd() // returns true if the current visible icon is the endIcon else false
I am closing the issues. If ther are any issues, feedback is always welcome.
Thanks for the quick update! This addresses both use cases I have. I just tested out the second one, and it works as expected.
Currently, the widget only switches between
start
andend
icons when a user taps on it. But there are 2 cases where I want more control over it. Ideally, the parent widget which includes the icon can specify exactly when to transition between thestart
vsend
icons.When there are multiple icons
Let's say there are 4
AnimateIcons
in a bottom app bar. When the user taps on the first one, it will go fromstart
toend
, which is expected.But when a user taps on any other icon, I expect the first one to revert back to
start
. Currently, there is no way to force this to happen. The first icon will be stuck inend
until a user taps on it again.When user input needs to be validated
Let's say there is a FAB with an
AnimateIcon
to switch between edit and save. When a user is in edit mode and clicks the FAB, I want it to animate to the save icon. This works as expected.But I want to validate user input before transitioning the icon. If the user input is invalid, I want to keep the user in edit mode and prevent transitioning the icon to the save icon.
Currently, there is no way to prevent the transition before I can do some validation. The icon will transition as soon as the user taps on it.