When assigning the Mock object, it needs to be of the Mock object type, not the BaseClass.
@GenerateMocks(MockSpec<ITransactionRepository>(as: #MockTransactionRepository),
)
void main()
{
....
ITransactionRepository baseObject = MockTransactionRepository(); // wrong
MockTransactionRepository mockObject = MockTransactionRepository(); // right
when(baseObject.method(any)); // results in compile error
when(mockObject.method(any)); // OK
...
}
Source: https://github.com/dart-lang/mockito/issues/364