0

A bunch of the classes I implemented (for mocking purposes) without null safety have compilation errors now. Take this example:

class MockProvider extends Mock implements Provider<String>{}

This throws the error:

'Object.toString' ('String Function()') isn't a valid concrete implementation of
'Diagnosticable.toString' ('String Function({DiagnosticLevel minLevel})').
dart(invalid_implementation_override)

Mocking Firestore does something similar:

class MockFirestore extends Mock implements FirebaseFirestore {}

This creates the following error:

'Object.==' ('bool Function(Object)') isn't a valid concrete 
implementation of 'FirebaseFirestore.==' ('bool Function(dynamic)')

How can I fix this?

Wilson Wilson
  • 3,296
  • 18
  • 50
  • 1
    Are you using Mockito 5.0.0, and have you read its [null-safety instructions](https://github.com/dart-lang/mockito/blob/master/NULL_SAFETY_README.md)? – jamesdlin Mar 01 '21 at 20:42
  • I’m using mock tail, but this seems to be beyond mocking. Implementing classes that override equality doesn’t work in general. – Wilson Wilson Mar 01 '21 at 22:41
  • What do you mean that "Implementing classes that override equality doesn't work in general"? Can you provide an example? – jamesdlin Mar 01 '21 at 22:58
  • I suppose using mocks to illustrate was a bad idea, I'll create a new more descriptive question. – Wilson Wilson Mar 02 '21 at 06:38

0 Answers0