title: Mockito mocked function returned Null
body: <p>I got stuck on making the test using Mockito. I'm trying to implement Clean Architect to the Flutter tutorial <a href="https://docs.flutter.dev/get-started/codelab" rel="nofollow noreferrer">https://docs.flutter.dev/get-started/codelab</a>. I've made a use case called <code>GetRandomWords</code> and an interface-adapter called <code>RandomWordsRepository</code> like so:</p>
  <pre><code>abstract class RandomWordsRepository {
    String get();
  }
  
  abstract class GetRandomWords {
    String randomWords();
  }
  
  class GetRandomWordsImpl implements GetRandomWords {
    final RandomWordsRepository repository;
  
    GetRandomWordsImpl(this.repository);
  
    @override
    String randomWords() {
      return repository.get();
    }
  
  }
  </code></pre>
  <p>I've made a test case like this:</p>
  <pre><code>import 'package:mockito/mockito.dart';
  import 'package:tutorial/domain/interfaces/random_words_repository.dart';
  import 'package:tutorial/domain/use_cases/get_random_words.dart';
  
  class MockRandomWordsRepository extends Mock implements RandomWordsRepository {
  }
  
  @GenerateMocks([RandomWordsRepository])
  void main() {
    setUp(() {});
  
    test(&quot;Should get random words from repository&quot;, () async {
      final expectedRandomWords = &quot;test_random_words&quot;;
      final mockRepository = MockRandomWordsRepository();
      final useCase = GetRandomWordsImpl(mockRepository);
      when(mockRepository.get()).thenReturn(expectedRandomWords);
      
      expect(useCase.randomWords(), expectedRandomWords);
      verify(mockRepository.get());
    });
  }
  </code></pre>
  <p>But it returned this error: <code>type 'Null' is not a subtype of type 'String'</code> on the line <code>when(mockRepository.get()).thenReturn(expectedRandomWords);</code>. Can anybody tell me what went wrong here?</p>