title: How to mock http request in flutter integration test?
body: <p>I'm trying to do so using Mockito, this is my test:</p>
  
  <pre class="lang-dart prettyprint-override"><code>import 'package:http/http.dart' as http;
  import 'package:utgard/globals.dart' as globals;
  import 'package:flutter_driver/flutter_driver.dart';
  import 'package:test/test.dart';
  import 'package:mockito/mockito.dart';
  
  class MockClient extends Mock implements http.Client {}
  
  void main() {
    group('Login flow', () {
  
      final SerializableFinder loginContinuePasswordButton =
          find.byValueKey('login_continue_password_button');
  
      FlutterDriver driver;
  
      setUpAll(() async {
        driver = await FlutterDriver.connect();
      });
  
      tearDownAll(() async {
        if (driver != null) {
          //await driver.close();
        }
      });
  
  
      test('login with correct password', () async {
        final client = MockClient();
  
        when(client.post('http://wwww.google.com'))
            .thenAnswer((_) async =&gt; http.Response('{"title": "Test"}', 200));
  
        globals.httpClient = client;
  
        await driver.enterText('000000');
        await driver.tap(loginContinuePasswordButton);
      });
    });
  }
  </code></pre>
  
  <p>And this is my http request code:</p>
  
  <pre class="lang-dart prettyprint-override"><code>Future&lt;Map&lt;String, dynamic&gt;&gt; post({
    RequestType requestType,
    Map&lt;String, dynamic&gt; body,
  }) async {
    final http.Response response =
        await globals.httpClient.post('http://wwww.google.com');
  
    print(response);
  
    final Map&lt;String, dynamic&gt; finalResponse = buildResponse(response);
  
    _managerErrors(finalResponse);
  
    return finalResponse;
  }
  </code></pre>
  
  <p>And here I have the global:</p>
  
  <pre class="lang-dart prettyprint-override"><code>library utgard.globals;
  
  import 'package:http/http.dart' as http;
  
  http.Client httpClient = http.Client();
  </code></pre>
  
  <p>However I continue to receive http errors, that indicates to me that the http wasn't replaced by the mock.</p>