Skip to content

Conversation

@Hixie
Copy link
Contributor

@Hixie Hixie commented Jul 21, 2017

  • Optimise AnimatedSize for the tight case.
  • Remove default from a switch statement over enum (so that analyzer will complain if we add enum values).
  • Adopt the Size since we use it after the child may have changed (which would throw normally).
  • AnimatedCrossFade.layoutBuilder

Copy link
Contributor

@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also _controller.stop()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

_controller.stop()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yeah good point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

merged these two blocks together and just made the layout use elvis:

    if (child == null || constraints.isTight) {                                                                                                                                                                                                             
      _controller.stop();                                                                                                                                                                                                                                   
      size = _sizeTween.begin = _sizeTween.end = constraints.smallest;                                                                                                                                                                                      
      _state = RenderAnimatedSizeState.start;                                                                                                                                                                                                               
      child?.layout(constraints);                                                                                                                                                                                                                           
      return;                                                                                                                                                                                                                                               
    }                                                                                                                                                                                                                                                       

Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated to changes in this PR: I wonder if the existence of this subclass causes the AOT compiler to believe that Size is polymorphic and makes it slower than it could be.

@rmacnak-google?

Copy link
Contributor

Choose a reason for hiding this comment

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

s/object/box/?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would make the later text confusing ("this second render object" wouldn't be as obvious), so I've left it as object.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: optimizations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed throughout the file

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add `See [AnimatedCrossFade.defaultLayoutBuilder] for an example implementation'.

I also wonder if the keys should be uniquely generated GlobalKeys instead, thus allowing more interesting layouts than those based on multiple children. In fact, I wonder if we would need to pass the keys here at all if they are GlobalKeys?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to avoid using global keys if at all possible. They're expensive.

You can always convert a LocalKey to a GlobalKey if you really need a global key on the receiving end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added your suggested text

Actually, i've just put in some sample code instead.

* Optimise AnimatedSize for the tight case.
* Remove `default` from a switch statement over enum (so that analyzer will complain if we add enum values).
* Adopt the Size since we use it after the child may have changed (which would throw normally).
* AnimatedCrossFade.layoutBuilder
@Hixie
Copy link
Contributor Author

Hixie commented Jul 21, 2017

updated. will land on green, if it ever goes green.

@Hixie Hixie merged commit 1f08bda into flutter:master Jul 21, 2017
@Hixie Hixie deleted the crossfade branch July 21, 2017 22:23
goderbauer added a commit that referenced this pull request Jul 24, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants