flutterdartnosuchmethoderror

NoSuchMethodError: tried to call a non-function, such as null


I had do some changes in the codebase of a project. At first glance the pipeline don't showed any problem and the changes was merged.

The deployed flutter web project was ok.

But in the local development run, in an other feature of the project I got "NoSuchMethodError: tried to call a non-function, such as null".

The problem discovered both in mac and windows environments.

Debugging with logger doesn't helped, a callable class object that logged ok the next moment was null!

and it was frustrating to find out what the reason was...


Solution

  • The reason was: circular package dependency!

    I realised that a project package had use some other package that use some other package that use again the first.

    (dependency validation tool had not showed any error)

    After I refactored my code the problem was solved!