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

Speed improvements and added more config #6

Merged
merged 5 commits into from
Nov 13, 2019
Merged

Speed improvements and added more config #6

merged 5 commits into from
Nov 13, 2019

Conversation

stargazing-dino
Copy link
Contributor

Hi! I love the package. My changes started out from wanting to avoid calling setState after reading this article: https://medium.com/flutter-community/flutter-laggy-animations-how-not-to-setstate-f2dd9873b8fc . It now uses animatedBuilders, responds to rebuilds with new parameters via didUpdateWidget and adds two fields: curve and isAnimating. The curve is for the alpha and the isAnimating is a flag to animate the glow or not.

The widget now uses animatedBuilders, responds to rebuilds with new parameters and adds two fields: curve and isAnimating. The curve is for the alpha and the isAnimating is a flag to animate the glow or not.
@apgapg
Copy link
Owner

apgapg commented Nov 12, 2019

Thanks for opening this PR. Will review soon.
@xsahil03x any comments?

Previously only created the animation if the isAnimating flag was true, but that would lead the AnimatedBuilder to throw since its animation was expected to not be null
didUpdateWidget will now only update the animation if animation related values are changed.
Had a mistake where I'd set the `controller.duration` to the `widget.controller`, but as that might not always be provided by, it'd go to null and error. The duration is now defaulted in the constructor list
final BoxShape shape;
final Duration duration;
final bool repeat;
final bool isAnimating;
Copy link
Contributor

Choose a reason for hiding this comment

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

The field name can be changed to something more meaningful, like a normal final bool animate. Just my views!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to just animate 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@Nolence Btw do we really need this animate field? As one will only use this package when he wants to show animation on his avatar. If this field is intended for play/pausing the animation, then I think the name should be changed again to something more meaningful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A previous issue wanted this feature and I currently use it for drawing attention to dragTargets that are willing to take an item (by toggling the GlowAvatar around them) so I don't think users will just use this package for avatars

Screen Shot 2019-11-12 at 11 33 11 AM

I don't have a preference on naming so long as others can understand the field. I can also add doc strings to all the fields in case we need more accessibility

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, Got your point. 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@apgapg we can merge the changes now.

Copy link
Owner

Choose a reason for hiding this comment

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

Yes sure. LGTM

@xsahil03x
Copy link
Contributor

@apgapg Apart from that field name, LGTM 👍

Renamed `isAnimating` -> `animate`. Also removed the 2 assignments inside of the `build` method (e.g. `final glowColor = widget.glowColor;`). The issue must've been a local thing as their initial warnings are now gone.
@apgapg
Copy link
Owner

apgapg commented Nov 13, 2019

Thanks @Nolence @xsahil03x for the contribution and feedback. Did a fantastic job

@apgapg
Copy link
Owner

apgapg commented Nov 13, 2019

JgNRalI

@apgapg apgapg merged commit 25cecf6 into apgapg:master Nov 13, 2019
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.

3 participants