-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Expose Ticker.startTime so users know the start time and the absolute time
#113828
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
Conversation
| /// When [_onTick], the callback is provided with a relative time (the | ||
| /// "elapsed"). By adding the `elapsed` to this [startTime], you can get the | ||
| /// absolute time. | ||
| Duration? get startTime => _startTime; |
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.
What does it mean when this returns null?
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.
When _startTime is really null. For example, a fresh new ticker that is created at idle period without ticked the first time - looking through Ticker code you can see it has startTime as null.
I guess we should not provide non-null assert here, because users of this field have no sufficient information to know whether it already has a value.
| /// [isTicking]. | ||
| bool get isActive => _future != null; | ||
|
|
||
| /// The start time of the ticker. |
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.
The Ticker is designed to measure relative time. I don't see a good reason to change that.
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.
Well it is required for flutter_smooth, mainly here: https://github.com/fzyzcjy/flutter_smooth/blob/0c5db0ff270aa0c8cff28ea19055999627a8df6d/packages/smooth/lib/src/drop_in/list_view/shift.dart#L352-L356
Shortly speaking, I need to know the time that the ListView animation is using, such that I can fully replicate it in an external extra SmoothShift.
|
So... What should I do now? I have already replied to all questions and it has been more than a week :) |
|
I don't think we should be exposing random implementation details like that. I would suggest filing an issue discussing the problem you're trying to solve without tying it to a particular solution. We can then see if this fixes that particular problem. |
|
I see, same as before, I will file soon when having time. Thanks! |
|
The requested issue is created and described the details: #115901 |
Currently, the user of
Tickeronly knows theelapsedtime. However, it looks reasonable to allow the user to know when the ticker thinks it starts ticking.If this does not wanted to be widely used, maybe we can mark it as
@protectedor@visibleForTestingor@experimental.As for where it is needed inside flutter_smooth, it is utilized to know the relative time between a few Tickers as well as the system. In other words, when Ticker A says it elapsed 1 second, flutter_smooth needs to know the startTime such that it knows what "1second" means in absolute time. Detailed code can be seen in https://github.com/fzyzcjy/flutter_smooth/blob/0c5db0ff270aa0c8cff28ea19055999627a8df6d/packages/smooth/lib/src/drop_in/list_view/shift.dart#L352-L356
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.