circular_countdown_timer
circular_countdown_timer copied to clipboard
Field _state has not been initialized...
after defining a controller, i get a LateInitializationError: Field _state@.... has not been initialized in Flutter error
here's my code
I had the same issue. I was able to resolve it by declaring the controller constructor inside of the timer constructor, like so:
CircularCountDownTimer( ... controller: CountDownController(), ... )
For me, the same.
This makes it quite impossible to do layer separation, since you will get the error.
I could somehow solve it, but when doing tests of the business logic, this leads to real problems.
It would be nice, if the controller could be used in all ways, even if the widget currently does not exist.
So one Controller, which is created at one place, can be reset, even if the time already passed.
Anyone able to solve this?
Unable to reproduce it, Can anyone please share the code that is causing this issue?
Just let the timer finish and then try to restart the controller timer with the corresponding function. Page with Timer and a button for the reset. After the timer is done, press the button to restart the controller.
OR
Use the controller, when it's not assigned to the widget.
I was facing this same issue, but the changed from a Stateless to a Stateful widget and it worked as expected.