Home > Mobile >  Flutter Chrome Debugging: API calls don't work at all
Flutter Chrome Debugging: API calls don't work at all

Time:04-29

I'm developing a simple web/Android Flutter App. Everything works fine on Android, but when I try debugging it on Chrome (web-javascript), none of my API calls work.

Debugger stops in ticker.dart > TickerFuture > _complete() and this message appears in the console, and the API call continues forever.

ChromeProxyService: Failed to evaluate expression '_primaryCompleter'

I've tried using CORS and try catch blocks to see if i can get more info about the error.

This is an example API call:

Future<bool> login(LoginData l) async {
    try {
      Uri url = Uri.parse(baseUrl   "/login/");

      final response = await http.post(url,
          body: {"email": l.name, "password": l.password},
          headers: {"Access-Control-Allow-Origin": "*"});
      if (response.statusCode == 200) {
        return response.body == "true";
      } else {
        throw Exception('Failed to load books');
      }
    } catch (e) {
      print(e);
      throw Exception('Failed to load books');
    }
  }

CodePudding user response:

There were some issues with debugging in Chrome after Chrome v100 released.

Flutter 2.10.5 was released to fix some of these issues:

https://github.com/flutter/flutter/wiki/Hotfixes-to-the-Stable-Channel#2105-april-18-2022

flutter/101224 - Flutter web debugger fails when using chrome 100 or greater.

  • Related