Again move mockito to 300plus2 (#15981)

* Revert "Revert "Move mockito to 3.0.0-alpha. (#15949)" (#15979)"

This reverts commit e59651f925917ed44a9bf27c37e80fc9992c0890.

* More thenReturn to thenAnswer when mocking Futures

* Revert "More thenReturn to thenAnswer when mocking Futures"

This reverts commit 194d2cf41754ad171efd6bb5898cf73bce5a75ab as we are reverting engine roll.

* Revert "Revert "More thenReturn to thenAnswer when mocking Futures""

This reverts commit 52c9e96b304b220f66d78a252fccea0c8e0ef24c.

* Add dependency override

* Fix issue
diff --git a/dev/bots/pubspec.yaml b/dev/bots/pubspec.yaml
index 29660bd..2d05400 100644
--- a/dev/bots/pubspec.yaml
+++ b/dev/bots/pubspec.yaml
@@ -21,7 +21,7 @@
 
 dev_dependencies:
   test: 0.12.32+2
-  mockito: 2.2.3
+  mockito: 3.0.0-alpha+2
 
   barback: 0.15.2+15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
   boolean_selector: 1.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
diff --git a/dev/manual_tests/pubspec.yaml b/dev/manual_tests/pubspec.yaml
index 4c533e5..d02c5e3 100644
--- a/dev/manual_tests/pubspec.yaml
+++ b/dev/manual_tests/pubspec.yaml
@@ -13,7 +13,7 @@
   flutter_test:
     sdk: flutter
 
-  mockito: 2.2.3
+  mockito: 3.0.0-alpha+2
 
   args: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
   async: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
diff --git a/dev/manual_tests/test/mock_image_http.dart b/dev/manual_tests/test/mock_image_http.dart
index 5446ee6..81703ed 100644
--- a/dev/manual_tests/test/mock_image_http.dart
+++ b/dev/manual_tests/test/mock_image_http.dart
@@ -11,9 +11,9 @@
   final MockHttpClientRequest request = new MockHttpClientRequest();
   final MockHttpClientResponse response = new MockHttpClientResponse();
   final MockHttpHeaders headers = new MockHttpHeaders();
-  when(client.getUrl(typed(any))).thenReturn(new Future<HttpClientRequest>.value(request));
+  when(client.getUrl(typed(any))).thenAnswer((_) => new Future<HttpClientRequest>.value(request));
   when(request.headers).thenReturn(headers);
-  when(request.close()).thenReturn(new Future<HttpClientResponse>.value(response));
+  when(request.close()).thenAnswer((_) => new Future<HttpClientResponse>.value(response));
   when(response.contentLength).thenReturn(kTransparentImage.length);
   when(response.statusCode).thenReturn(HttpStatus.OK);
   when(response.listen(typed(any))).thenAnswer((Invocation invocation) {
diff --git a/dev/tools/pubspec.yaml b/dev/tools/pubspec.yaml
index 2b5f504..5f0f4d7 100644
--- a/dev/tools/pubspec.yaml
+++ b/dev/tools/pubspec.yaml
@@ -24,7 +24,7 @@
 
 dev_dependencies:
   test: 0.12.32+2
-  mockito: 2.2.3
+  mockito: 3.0.0-alpha+2
 
   barback: 0.15.2+15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
   boolean_selector: 1.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
diff --git a/packages/flutter/pubspec.yaml b/packages/flutter/pubspec.yaml
index e2f5df35..0666d80 100644
--- a/packages/flutter/pubspec.yaml
+++ b/packages/flutter/pubspec.yaml
@@ -16,7 +16,7 @@
 dev_dependencies:
   flutter_test:
     sdk: flutter
-  mockito: 2.2.3
+  mockito: 3.0.0-alpha+2
 
   args: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
   async: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
diff --git a/packages/flutter/test/cupertino/refresh_test.dart b/packages/flutter/test/cupertino/refresh_test.dart
index af07d23..c91c039 100644
--- a/packages/flutter/test/cupertino/refresh_test.dart
+++ b/packages/flutter/test/cupertino/refresh_test.dart
@@ -59,7 +59,7 @@
       }
       return refreshIndicator;
     });
-    when(mockHelper.refreshTask()).thenReturn(refreshCompleter.future);
+    when(mockHelper.refreshTask()).thenAnswer((_) => refreshCompleter.future);
   });
 
   SliverList buildAListOfStuff() {
diff --git a/packages/flutter/test/widgets/image_headers_test.dart b/packages/flutter/test/widgets/image_headers_test.dart
index a7e94d8..3b563b5 100644
--- a/packages/flutter/test/widgets/image_headers_test.dart
+++ b/packages/flutter/test/widgets/image_headers_test.dart
@@ -27,9 +27,9 @@
       verify(headers.add('flutter', 'flutter')).called(1);
 
     }, createHttpClient: (SecurityContext _) {
-      when(client.getUrl(typed(any))).thenReturn(new Future<HttpClientRequest>.value(request));
+      when(client.getUrl(typed(any))).thenAnswer((_) => new Future<HttpClientRequest>.value(request));
       when(request.headers).thenReturn(headers);
-      when(request.close()).thenReturn(new Future<HttpClientResponse>.value(response));
+      when(request.close()).thenAnswer((_) => new Future<HttpClientResponse>.value(response));
       when(response.contentLength).thenReturn(kTransparentImage.length);
       when(response.statusCode).thenReturn(HttpStatus.OK);
       when(response.listen(typed(any))).thenAnswer((Invocation invocation) {
diff --git a/packages/flutter_driver/pubspec.yaml b/packages/flutter_driver/pubspec.yaml
index 3dd98b7..52ee8d8 100644
--- a/packages/flutter_driver/pubspec.yaml
+++ b/packages/flutter_driver/pubspec.yaml
@@ -66,7 +66,7 @@
 
 dev_dependencies:
   test: 0.12.32+2
-  mockito: 2.2.3
+  mockito: 3.0.0-alpha+2
   quiver: 0.28.0
 
 # PUBSPEC CHECKSUM: 74e9
diff --git a/packages/flutter_driver/test/flutter_driver_test.dart b/packages/flutter_driver/test/flutter_driver_test.dart
index 42962d8..9e2eb40 100644
--- a/packages/flutter_driver/test/flutter_driver_test.dart
+++ b/packages/flutter_driver/test/flutter_driver_test.dart
@@ -37,9 +37,9 @@
       mockVM = new MockVM();
       mockIsolate = new MockIsolate();
       mockPeer = new MockPeer();
-      when(mockClient.getVM()).thenReturn(new Future<MockVM>.value(mockVM));
+      when(mockClient.getVM()).thenAnswer((_) => new Future<MockVM>.value(mockVM));
       when(mockVM.isolates).thenReturn(<VMRunnableIsolate>[mockIsolate]);
-      when(mockIsolate.loadRunnable()).thenReturn(new Future<MockIsolate>.value(mockIsolate));
+      when(mockIsolate.loadRunnable()).thenAnswer((_) => new Future<MockIsolate>.value(mockIsolate));
       when(mockIsolate.invokeExtension(typed(any), typed(any))).thenAnswer(
           (Invocation invocation) => makeMockResponse(<String, dynamic>{'status': 'ok'}));
       vmServiceConnectFunction = (String url) {
diff --git a/packages/flutter_localizations/pubspec.yaml b/packages/flutter_localizations/pubspec.yaml
index 146e837..a7ccc3e 100644
--- a/packages/flutter_localizations/pubspec.yaml
+++ b/packages/flutter_localizations/pubspec.yaml
@@ -15,7 +15,7 @@
 dev_dependencies:
   flutter_test:
     sdk: flutter
-  mockito: 2.2.3
+  mockito: 3.0.0-alpha+2
 
   args: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
   async: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart
index 1c0b8b3..20d39e9 100644
--- a/packages/flutter_tools/lib/src/commands/update_packages.dart
+++ b/packages/flutter_tools/lib/src/commands/update_packages.dart
@@ -27,6 +27,7 @@
 /// ```
 const Map<String, String> _kManuallyPinnedDependencies = const <String, String>{
   // Add pinned packages here.
+  'mockito': '3.0.0-alpha+2', // TODO(aam): https://github.com/dart-lang/mockito/issues/110
 };
 
 class UpdatePackagesCommand extends FlutterCommand {
diff --git a/packages/flutter_tools/pubspec.yaml b/packages/flutter_tools/pubspec.yaml
index 8be98d1..55a8fbd 100644
--- a/packages/flutter_tools/pubspec.yaml
+++ b/packages/flutter_tools/pubspec.yaml
@@ -81,7 +81,7 @@
 
 dev_dependencies:
   collection: 1.14.6
-  mockito: 2.2.3
+  mockito: 3.0.0-alpha+2
 
 dartdoc:
   # Exclude this package from the hosted API docs.
diff --git a/packages/flutter_tools/test/channel_test.dart b/packages/flutter_tools/test/channel_test.dart
index b3bc3c8..4dadb3d 100644
--- a/packages/flutter_tools/test/channel_test.dart
+++ b/packages/flutter_tools/test/channel_test.dart
@@ -46,14 +46,14 @@
       ]);
       final Process process = new MockProcess();
 
-      when(process.stdout).thenReturn(stdout);
-      when(process.stderr).thenReturn(const Stream<List<int>>.empty());
-      when(process.exitCode).thenReturn(new Future<int>.value(0));
+      when(process.stdout).thenAnswer((_) => stdout);
+      when(process.stderr).thenAnswer((_) => const Stream<List<int>>.empty());
+      when(process.exitCode).thenAnswer((_) => new Future<int>.value(0));
       when(mockProcessManager.start(
         <String>['git', 'branch', '-r'],
         workingDirectory: typed(any, named: 'workingDirectory'),
         environment: typed(any, named: 'environment')))
-      .thenReturn(new Future<Process>.value(process));
+      .thenAnswer((_) => new Future<Process>.value(process));
 
       final ChannelCommand command = new ChannelCommand();
       final CommandRunner<Null> runner = createTestCommandRunner(command);
diff --git a/packages/flutter_tools/test/compile_test.dart b/packages/flutter_tools/test/compile_test.dart
index 4d1fb9d..c36edd8 100644
--- a/packages/flutter_tools/test/compile_test.dart
+++ b/packages/flutter_tools/test/compile_test.dart
@@ -30,7 +30,7 @@
       when(mockFrontendServer.stderr)
           .thenAnswer((Invocation invocation) => mockFrontendServerStdErr);
       final StreamController<String> stdErrStreamController = new StreamController<String>();
-      when(mockFrontendServerStdErr.transform<String>(any)).thenReturn(stdErrStreamController.stream);
+      when(mockFrontendServerStdErr.transform<String>(any)).thenAnswer((_) => stdErrStreamController.stream);
       when(mockFrontendServer.stdin).thenReturn(mockFrontendServerStdIn);
       when(mockProcessManager.canRun(any)).thenReturn(true);
       when(mockProcessManager.start(any)).thenAnswer(
diff --git a/packages/fuchsia_remote_debug_protocol/pubspec.yaml b/packages/fuchsia_remote_debug_protocol/pubspec.yaml
index eb8f47f..d6ac6ed 100644
--- a/packages/fuchsia_remote_debug_protocol/pubspec.yaml
+++ b/packages/fuchsia_remote_debug_protocol/pubspec.yaml
@@ -62,7 +62,7 @@
   yaml: 2.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
 
 dev_dependencies:
-  mockito: 2.2.3
+  mockito: 3.0.0-alpha+2
   test: 0.12.32+2
 
 # PUBSPEC CHECKSUM: 97d6
diff --git a/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart b/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart
index 172a9a8..b3f9cd7 100644
--- a/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart
+++ b/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart
@@ -31,7 +31,7 @@
       const String interface = 'eno1';
       // Adds some extra junk to make sure the strings will be cleaned up.
       when(mockRunner.run(typed(any)))
-      .thenReturn(new Future<List<String>>.value(
+      .thenAnswer((_) => new Future<List<String>>.value(
           <String>['123\n\n\n', '456  ', '789']));
       when(mockRunner.address).thenReturn(address);
       when(mockRunner.interface).thenReturn(interface);
@@ -100,7 +100,7 @@
           mockPeerConnections.add(mp);
           uriConnections.add(uri);
           when(mp.sendRequest(typed<String>(any), typed<String>(any)))
-              .thenReturn(new Future<Map<String, dynamic>>(
+              .thenAnswer((_) => new Future<Map<String, dynamic>>(
                   () => flutterViewCannedResponses[flutterViewIndex++]));
           return mp;
         });
diff --git a/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart b/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart
index aec9690..2e47c46 100644
--- a/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart
+++ b/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart
@@ -86,7 +86,7 @@
       Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
         when(mockPeer.sendRequest(
                 typed<String>(any), typed<Map<String, dynamic>>(any)))
-            .thenReturn(new Future<Map<String, dynamic>>(
+            .thenAnswer((_) => new Future<Map<String, dynamic>>(
                 () => flutterViewCannedResponses));
         return new Future<json_rpc.Peer>(() => mockPeer);
       }
@@ -135,7 +135,7 @@
       Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
         when(mockPeer.sendRequest(
                 typed<String>(any), typed<Map<String, dynamic>>(any)))
-            .thenReturn(new Future<Map<String, dynamic>>(
+            .thenAnswer((_) => new Future<Map<String, dynamic>>(
                 () => flutterViewCannedResponseMissingId));
         return new Future<json_rpc.Peer>(() => mockPeer);
       }
@@ -173,7 +173,7 @@
       Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
         when(mockPeer.sendRequest(
                 typed<String>(any), typed<Map<String, dynamic>>(any)))
-            .thenReturn(new Future<Map<String, dynamic>>(
+            .thenAnswer((_) => new Future<Map<String, dynamic>>(
                 () => flutterViewCannedResponseMissingIsolateName));
         return new Future<json_rpc.Peer>(() => mockPeer);
       }
@@ -208,7 +208,7 @@
         // Return a command that will never complete.
         when(mockPeer.sendRequest(
                 typed<String>(any), typed<Map<String, dynamic>>(any)))
-            .thenReturn(new Completer<Map<String, dynamic>>().future);
+            .thenAnswer((_) => new Completer<Map<String, dynamic>>().future);
         return new Future<json_rpc.Peer>(() => mockPeer);
       }
 
diff --git a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart
index 83f7fbc..6488018 100644
--- a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart
+++ b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart
@@ -40,8 +40,8 @@
     setUp(() {
       mockProcessManager = new MockProcessManager();
       mockProcessResult = new MockProcessResult();
-      when(mockProcessManager.run(typed(any))).thenReturn(
-          new Future<MockProcessResult>.value(mockProcessResult));
+      when(mockProcessManager.run(typed(any))).thenAnswer(
+          (_) => new Future<MockProcessResult>.value(mockProcessResult));
     });
 
     test('verify interface is appended to ipv6 address', () async {