Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@parlough
Copy link
Member

@parlough parlough commented Jul 17, 2025

TimeRange represents the range between two start and end times marked in microseconds (so a duration). However, it stored start and end as Duration as well, resulting in the existence of three durations which was a bit confusing as I worked to understand code using TimeRange.

Beyond that, TimeRange was not immutable so had a concept of being "well formed" (or having both a start and end), resulting in multiple checks for that state and many not-null assertion operations. To maintain the intermediate status and also reduce the necessity of the not-null assertions, split out the intermediate state to a new TimeRangeBuilder class with a build method that consolidates the not-null assertions to that singular function.

@parlough parlough force-pushed the misc/time-range-cleanup branch from eaaaf4e to 87e29cd Compare July 17, 2025 13:07
@parlough parlough marked this pull request as ready for review July 18, 2025 10:26
@parlough parlough requested review from a team, bkonyi and kenzieschmoll as code owners July 18, 2025 10:26
Copy link
Member

@elliette elliette left a comment

Choose a reason for hiding this comment

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

A couple comments but this looks good, thank you!

@parlough parlough requested a review from elliette July 24, 2025 20:13
@parlough parlough merged commit 119684c into flutter:master Jul 25, 2025
41 checks passed
@parlough parlough deleted the misc/time-range-cleanup branch July 25, 2025 06:43
hrajwade96 pushed a commit to hrajwade96/devtools that referenced this pull request Sep 2, 2025
…er#9325)

`TimeRange` represents the range between two `start` and `end` times marked in microseconds (so a duration). However, it stored `start` and `end` as `Duration` as well, resulting in the existence of three durations which was a bit confusing as I worked to understand code using `TimeRange`.

Beyond that, `TimeRange` was not immutable so had a concept of being "well formed" (or having both a start and end), resulting in multiple checks for that state and many not-null assertion operations. To maintain the intermediate status and also reduce the necessity of the not-null assertions, split out the intermediate state to a new `TimeRangeBuilder` class with a `build` method that consolidates the not-null assertions to that singular function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants