How to intercept native network requests in Flutter?

Viewed 179

I'm using Flutter Devtools to inspect network traffic. Flutter requests made via e.g. the http package are indeed tracked, but requests coming from the underneath native iOS and Android apps are not.

Example:

print("sending request from native iOS.")
let url = URL(string: "http://www.stackoverflow.com")!

let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
  guard let data = data else { return }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

In the above example, not only that the network request isn't captured, but I can't even see the print in Flutter's Android Studio console.

I want to track the native requests and check in e2e tests if they are sent, but currently don't understand why this is not happening by default.

0 Answers
Related