-
Notifications
You must be signed in to change notification settings - Fork 364
Add animated opacity to the flex layout children. #1390
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
Add animated opacity to the flex layout children. #1390
Conversation
a21b3a1 to
71f4e68
Compare
| child: AnimatedBuilder( | ||
| animation: entranceController, | ||
| builder: buildEntranceAnimation, | ||
| child: WidgetVisualizer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This widget tree is too deeply nested to be easily understood. Since changing any part of it also changes the indentation of the entire tree, we'll get more merge conflicts working on it together.
A helpful way to manage this is to break the method up into helper methods or to create new helper widget classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree Dave, initially I was going to make a helper widget class for the child but decided not to do that because I was still changing it a lot and I want to avoid 'prop drilling' into the class and just make use of the scope.
But since the implementation has become more complex, I agree splitting it is helpful.
Should I take this one then? @DaveShuckerow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need now, just pointing it out for future improvements. I want you focused on making this work off of Flutter master.
It's perfectly OK to write simple code then realize you need to refactor code later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, will do then, thanks Dave 👍
albertusdev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .map((renderSize) => renderSize.height)) | ||
| : maxHeight, | ||
| ), | ||
| ).normalize(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was running into an issue where resizing the screen would sometimes break the box constraints here. I suspect it was a precision glitch in the constraint calculations, and normalizing has fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the cross axis empty space calculation is still buggy now, I'll fix that soon, thanks Dave :-)
| horizontal: (renderSize.width - size.width) / 2, | ||
| vertical: (renderSize.height - size.height) / 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nit: * 0.5 instead of / 2 for consistency ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's nothing wrong with using division to express division.
I'm also not sure where else there's a *0.5 in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's in inspector_data_models.dart where I do the computation for the empty space. But yes it's fine
| super.initState(); | ||
| entranceController = AnimationController( | ||
| vsync: this, | ||
| duration: const Duration(milliseconds: 500), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: make the duration into const maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I mean, extract it into top level const?
| const defaultMaxRenderHeight = 300.0; | ||
|
|
||
| /// The size to shrink a widget by when animating it in. | ||
| const entranceMargin = 60; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 60.0 to avoid casting into double since margin is double?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.

cc @albertusangga