Error: Call to a member function resize() on null