Skip to content

Conversation

@fsayfitdinov
Copy link

When progress change, there is no any smooth animation, I have added animationController to handle this

duration: _animationDuration,
curve: Curves.ease,
);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the progress should be completed when the action is done.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the code. Now the _progressAnimationController is told to animate to 1.0 (or 100%) when the action completes, regardless of whether the action was successful or not. This should ensure that the progress bar completes before switching back to the non-progress state.

setState(() {
_progress = null;
});
_isInProgress = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will this work properly without setState?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AnimatedBuilder widget listens to the AnimationController and rebuilds whenever the animation changes, therefore if _isInProgress is changed at the same time as the animation value, the AnimatedBuilder should capture that change without requiring a setState().

}
}
Widget build(BuildContext context) => AnimatedBuilder(
animation: _progressAnimationController!,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the _progressAnimationController is nullable, then we should never forcefully use it without null check

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I made a mistake here. Actually the _progressAnimationController is not nullable

@adar2378
Copy link
Contributor

Hi @fsayfitdinov Thank you for the PR. The idea is nice. But I think the codes have some bugs. Please check my feedback. If you have any confusion please reach me on Slack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants