Skip to content

Conversation

@matthew-carroll
Copy link
Contributor

Adds the ability to linearly interpolate Durations.

@flutter-dashboard flutter-dashboard bot added framework flutter/packages/flutter repository. See also f: labels. work in progress; do not review labels Aug 26, 2020
@matthew-carroll
Copy link
Contributor Author

@cbracken I moved the lerpDuration implementation to Foundation and I used your lerpDouble tests for inspiration.

@Hixie I placed lerpDuration within basic_types.dart. Does that seem like a reasonable place to put it? And if so, does it also seem reasonable to place the tests in a new basic_types_test.dart?

WRT to the tests, are there specific edge-case values that you believe are important here? I know you mentioned large numbers, infinity, and NaN WRT to lerpDouble. I altered this implementation to only accept non-null Durations because I think that's a reasonable restriction, which then defers the handling of various numerical values to Duration, itself. As for the t value, I'm not sure what the expected behavior should be for infinity or NaN. I suppose infinity should produce infinity, and NaN sounds like it deserves an exception. Thoughts?

@Hixie
Copy link
Contributor

Hixie commented Aug 26, 2020

This all looks great. Durations can't be NaN or Infinity so no worries there. Supporting non-null only seems fine, it's not clear what a null Duration would mean. basic_types.dart seems fine.

Copy link
Contributor

@Hixie Hixie left a comment

Choose a reason for hiding this comment

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

LGTM, but travis is angry.

...I really need to update this stamp to refer to tests in general since we don't use Travis anymore...

Copy link
Member

@goderbauer goderbauer 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
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

LGTM, but looks like presubmit is failing.

Animated GIF of a delivery truck approaching a highway overpass, then failing to meet the height clearance requirement and crashing into it

return Duration(
microseconds: (a.inMicroseconds + (b.inMicroseconds - a.inMicroseconds) * t).round(),
);
}
Copy link
Member

Choose a reason for hiding this comment

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

Here and below: Very minor nit, source files should end with a linefeed. That said, that's probably more pedantic than anything -- I'm 99% certain that the entire Dart toolchain consistently handles this just fine without it. But not a bad idea anyway.

@fluttergithubbot fluttergithubbot merged commit 57b6952 into flutter:master Aug 27, 2020
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants