circular_countdown_timer icon indicating copy to clipboard operation
circular_countdown_timer copied to clipboard

Field _state has not been initialized...

Open ThisIsMonta opened this issue 3 years ago • 6 comments

after defining a controller, i get a LateInitializationError: Field _state@.... has not been initialized in Flutter error

here's my code code_example

ThisIsMonta avatar Jan 30 '22 00:01 ThisIsMonta

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(), ... )

sdsherm avatar May 03 '22 20:05 sdsherm

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.

thomasklaush avatar Jun 01 '22 19:06 thomasklaush

Anyone able to solve this?

imprisonedmind avatar Jun 14 '22 08:06 imprisonedmind

Unable to reproduce it, Can anyone please share the code that is causing this issue?

MuhammadUsamaSiddiqui avatar Jun 24 '22 07:06 MuhammadUsamaSiddiqui

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.

thomasklaush avatar Jun 24 '22 08:06 thomasklaush

I was facing this same issue, but the changed from a Stateless to a Stateful widget and it worked as expected.

daniel-hopkins avatar Oct 26 '22 11:10 daniel-hopkins