title: How to verify to call or not to call a method
body: <pre><code>class MockView extends Mock implements ContactListViewContract {
  
    @override
    void onLoadContactsComplete(List&lt;Contact&gt; items) {
  
    }
    @override
    void onLoadContactsError() {}
  
  }
  
  void main() {
  
    test('ContactListPresenter test', () {
      Injector.configure(Flavor.MOCK);
      MockView view = new MockView();
  
      ContactListPresenter presenter = new ContactListPresenter(view);
  
      presenter.loadContacts();
  
      verify(view.onLoadContactsComplete).called(1);
  
    });
  
  }
  </code></pre>
  
  <p>I want to make sure when <code>presenter.loadContacts()</code> is called from the code, then verify <code>view.onLoadContactsComplete</code> is called also but getting an error: </p>
  
  <blockquote>
    <p>Used on a non-mockito object</p>
  </blockquote>
  
  <p>Is there a possibility to do this with Mockito?</p>
  
  <p>Update:</p>
  
  <pre><code>abstract class ContactListViewContract {
    void onLoadContactsComplete(List&lt;Contact&gt; items);
    void onLoadContactsError();
  }
  </code></pre>
  
  <p>here the <code>onLoadContactsComplete</code> method is called   </p>
  
  <pre><code>class ContactListPresenter {
    ContactListViewContract _view;
    ContactRepository _repository;
  
    ContactListPresenter(this._view){
      _repository = new Injector().contactRepository;
    }
  
    void loadContacts(){
      assert(_view != null);
  
      _repository.fetch()
          .then((contacts) {
            print(contacts);
            _view.onLoadContactsComplete(contacts); // here the onLoadContactsComplete method is called
          }).catchError((onError) {
            print(onError);
            _view.onLoadContactsError();
          });
    }
  
  }
  </code></pre>
  
  <p>Mocked Repository. Fetch mocked data.</p>
  
  <pre><code>class MockContactRepository implements ContactRepository{
  
    Future&lt;List&lt;Contact&gt;&gt; fetch(){
      return new Future.value(kContacts);
    }
  
  }
  </code></pre>