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
Request: Being able to access current state of timer #18
Comments
First of all, if we go back to using Running something like this 1000 times actually takes more than 1 second: const Duration interval = Duration(milliseconds: 1);
Timer.periodic(interval, (_) => time += interval); It even happens with a smaller interval like 10 milliseconds. But if we ignore that and make the controller the source of truth and still use Suppose that from now on we forget about milliseconds and only work with seconds, we would still get some problems:
Returning to the main topic of the problem. I agree that it would be a nice feature, as would being able to change the current value. We could achieve it in some dirty way, but I prefer to avoid it and it would also still depend on the view. If you do not consider the points mentioned important and we take the current value to the controller (including So, do you really need this package or maybe it's a better idea to write your own class tailored to your project? Maybe you will find more points against the current approach or more benefits of making this change that would be great to know. |
Yes I agree that it isn't feasible to run it for milliseconds at this moment, perhaps theres a solution where the animation and Those are good points but for my current use cases those points don't make much of a difference as it doesn't need to be that time critical. I have actually already done it using Timer in my fork here :) I needed to get the ball rolling on this but I'm happy to put up a PR or iterate on my changes before doing so. I admit clean code was not top of my mind as I just wanted to get something working but it does well for having the controller be the source of truth and controlling the timer from within other parts of my app. |
I found this article related to this topic. Mention some important points of using I recently updated this package, with the goal of making the controller the source of truth for the timer. I'll close this for now, though I'd like to hear your thoughts on these changes. |
@federicodesia It looks great man! Big quality of life improvement and I think a lot of people looking for a flutter timer package will turn to this now. One small function people might find useful is to have a function to add/remove time from the timer. I personally just stored the controller in my global store but I would leave that up to the consumer of the package. Something to think about would be maybe changing the package name to just flutter_timer or along those lines so it comes up more when people are searching for a timer in flutter. I'm not sure how that would affect pub dev ratings though. Also a PR would be nice next time a major change happens to provide all context in one spot and describe any changes as this project gains visibility. I know this is your baby but something to keep in mind for the future. Happy to help and thanks for making the package better! |
Thank you for your feedback!
This is something similar to what I'm currently working on. So far it is not possible to modify _controller.begin = Duration(hours: 12); So after that, allowing something like Yes, the package name is definitely a bit tricky, although names like flutter_timer are taken. If you find an easier one please let me know! I will keep what you say about PR in mind for major changes! |
@leo-paz The |
@federicodesia Thats awesome dude, I think you should highlight the new methods in the README features along with For package names, maybe something like flutter_timekeeper or even something like flutter_ticktock? I feel like people resonate with humour haha but ultimately up to you! Haha of course it was great helping out :) |
It would be nice to be have the controller be able to keep track of the timer regardless of whether or not the timer is in view or not.
I envision the controller being the source of truth for the timer widget and the widget simply latches on to the current state of the controller it was initialized with whenever it comes into view. This way we can get and set the timer from just the controller in other parts of an app.
The initial discussions for this issue can be found here.
The text was updated successfully, but these errors were encountered: