'LateInitializationError when testing

My variable has been initialized but I still get LateInitializationError. I only get this during testing, it works fine normally. Logs:

Closure: () => void from Function 'updateLight':. // This is the value of variable being printed

══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
The following LateError was thrown while handling a gesture:
LateInitializationError: Field 'updateMethod' has not been initialized.

I can print the variable which is to be used, which means it has been initialized.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source