Warning when mocking a class

Viewed 185

I am reading this article - https://www.dartlang.org/articles/mocking-with-dart/ - about mocking wiht Dart and have gotten this simple example working.

import 'package:unittest/mock.dart';

class Foo {
  int x;
  bar() => 'bar';
  baz() => 'baz';
}

class MockFoo extends Mock implements Foo {}

void main() {
  var mockFoo = new MockFoo();
  mockFoo.when(callsTo('bar')).
      thenReturn('BAR');

  print(mockFoo.bar());
}

The code prints 'BAR' correctly, so the mocking clearly works. But the Dart Editor generates a warning/error:

Missing inherited members: 'Foo.bar', 'Foo.baz' and 'Foo.x'

Despite this warning/error, the code seems to work but I would like to get rid of the error. How do I do that?

2 Answers
Related