What can I do to prevent the compiler from throwing the following warning
Missing concrete implementation of setter 'MyClass.field' and getter 'MyClass.field'
on the following code?
import 'package:mock/mock.dart';
class MyClass {
String field;
}
@proxy
class MockMyClass extends Mock implements MyClass{}
Implement noSuchMethod();
When a class has a noSuchMethod()
it implements any method. I assume this applies to getter/setter as well because they are just special methods (never tried myself yet though). See also https://www.dartlang.org/articles/emulating-functions/#interactions-with-mirrors-and-nosuchmethod
The warning comes because you have a class that doesn't implement its interface, and which doesn't declare a noSuchMethod
method.
It's not sufficient to inherit the method, you have to actually declare it in the class itself.
Just add:
noSuchMethod(Invocation i) => super.noSuchMethod(i);
That should turn off the warning for that class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With