flutter test fails. compiler error getter not found 'main' flutter test fails. compiler error getter not found 'main' dart dart

flutter test fails. compiler error getter not found 'main'


In my case, it happened that one of my helper classes in the test folder, had a name that ended "_test", and the compiler was looking for a main method. So I renamed the helper class, and problem solved.


If anybody faces the above problem then try to add main() in test class and if you have added then remove it out of test class curly braces. I faced this and removed the main() out of test class.

Eg...

class GetConcreteNumberTrivia_Test extends Mock    implements NumberTriviaRepository {}void main() {.....my implementation......}


I had this error when a merge mess put the main() within a class.