-
Notifications
You must be signed in to change notification settings - Fork 166
DiagnosticableMixin.toString' ('String Function({minLevel: DiagnosticLevel}) isnt a valid override of 'Mock.toString' ('String Function()'). #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You mention that this looks similar to #228, but your two code snippets do not reference each other: abstract class MockWithExpandedToString extends Mock {
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.debug });
} and import 'package:mockito/mockito.dart';
class TestData extends Mock implements BookingFormState {} Should TestData extend MockWithExpandedToString instead of Mock? |
Yes you're right, i updated my first comment. I tried it with MockWithExpandedToString but no succes. You have any idea what else it can be @srawlins ? |
We need a complete, reproducing example. I don't see where BookingFormState is. I don't see how I don't think "DiagnosticableMixin.toString' ('String Function({minLevel: DiagnosticLevel}) isnt a valid override of 'Mock.toString' ('String Function()')." would show up if |
@srawlins The reason why "isn't" was misspelled was because of me. I didn't copy the error but typed it over. For my code i made a repository : https://github.com/SenadK95/vitalforest . |
Thanks for uploading a code repo. It does not reference Mockito though. |
This is really easy to reproduce if you attempt to mock a widget that inherits from InheritedWidget. |
Adding the manual override of This has static errors: import 'package:mockito/mockito.dart';
class Foo {
@override
String toString({String extra}) => extra ?? 'default';
}
class MockFoo extends Mock implements Foo {} This fixes the errors: import 'package:mockito/mockito.dart';
class Foo {
@override
String toString({String extra}) => extra ?? 'default';
}
class MockFoo extends Mock implements Foo {
@override
String toString({String extra}) => super.toString();
} You can either copy/paste this into your mocks: @override
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.debug }) => super.toString(); Or you can define it once: abstract class MockWithDiagnosticToString extends Mock {
@override
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.debug }) => super.toString();
} Then replace Closing since this can be worked around locally and there are no actions to take in this package. |
'Hello i keep getting the following error while using mockito :
DiagnosticableMixin.toString' ('String Function({minLevel: DiagnosticLevel}) isnt a valid override of 'Mock.toString' ('String Function()').
i already tried :
abstract class MockWithExpandedToString extends Mock {
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.debug });
}
but this didn't work for me.
import 'package:mockito/mockito.dart';
class TestData extends MockWithExpandedToString implements BookingFormState {}
anyone knows how to fix this ?
The text was updated successfully, but these errors were encountered: