Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a "missing concrete implementation" warning be suppressed?

Tags:

warnings

dart

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{}
like image 416
richard Avatar asked May 16 '15 09:05

richard


2 Answers

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

like image 134
Günter Zöchbauer Avatar answered Sep 23 '22 10:09

Günter Zöchbauer


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.

like image 35
lrn Avatar answered Sep 23 '22 10:09

lrn