7

This is the first request my app executes in order to log in the user. On android, every request works fine but, for some reason, on iOS they don't seem to be executed. I already have set up the developer options on the simulator to allow HTTP Services. I have also tested the code on a physical iPad, and it won't execute the request.

During testing i am not using any timeout for this and if I leave the code running for a while once I have triggered the request, i get this log (it might not be relevant for this, but since i don't know what it is, I will attach it too):

[C1.1 958047F2-81ED-4A34-AEDE-A23D2CD6B49F 172.20.129.134:51780<->216.58.211.42:443]
Connected Path: satisfied (Path is satisfied), interface: en0
Duration: 240.322s, DNS @0.002s took 0.008s, TCP @0.017s took 0.014s, TLS took 0.287s
bytes in/out: 4769/1077, packets in/out: 9/10, rtt: 0.016s, retransmitted packets: 1, out-of-order packets: 0

Here's the code:

Future<LoginResponse> login(String login, String password, AppLocalizations locale) async {

    final response = await http.post(_url, body: {
      "module": _moduleLogin,
      "user": login,
      "pass": password,
      "lang": locale.localeName
    });

    try{
      EventManager manager = EventManager.getInstance();
      manager.clearAllEvents();
    }catch(e){
      print(e);
    }

    if (response.statusCode == 200) {
      return LoginResponse.fromJson(jsonDecode(response.body));
    } else {
      throw Exception('Failed to connect to webservice');
    }}

At this point I don't know what can be causing this problem. I am using the latest version of the http package.

Here's my flutter doctor output:

[✓] Flutter (Channel beta, v0.9.4, on Mac OS X 10.14 18A391, locale es-ES)
    • Flutter version 0.9.4 at /Users/alex/Documents/Development/flutter
    • Framework revision f37c235c32 (4 months ago), 2018-09-25 17:45:40 -0400
    • Engine revision 74625aed32
    • Dart version 2.1.0-dev.5.0.flutter-a2eb050044

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/alex/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 27.0.3
    • ANDROID_HOME = /Users/alex/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 26.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 26.0.2
    • Dart plugin version 181.4445.29

[✓] VS Code (version 1.30.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.21.1

[✓] Connected devices (1 available)
    • iPhone XS • 5FB9A137-7AB3-46B5-94BC-9562B0E5E752 • ios • iOS 12.1 (simulator)

• No issues found!
5
  • 1
    Why don't you fill it a bug on Github? Commented Jan 18, 2019 at 12:15
  • @CopsOnRoad will do. If I find an answer that way i will post it here. Commented Jan 18, 2019 at 15:31
  • @FunnyStunny, Did you managed to fix the issue? Commented Mar 21, 2019 at 9:46
  • @Sreegth I didn't. opened an issue and am still waiting for a response. I have opened it in dart-lang/http and in flutter/flutter. Will update this question whenever i get an answer or i manage to fix it myself. Im working on other things at this moment, thats why its taking long to close this. Commented Mar 22, 2019 at 10:13
  • not working for me as well on android. i.e works well on debug. I raised an issue on Github but no response. Commented May 1, 2019 at 16:39

1 Answer 1

5

Figured out a solution even though I don't know why does it work.

I replaced the http package with the dio package and it worked fine on both platforms.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.