ajax function
Sends an Ajax request to the given url and returns the response.
Same semantics as package:http's top-level functions (http.get,
http.put, …): body is buffered into the returned http.Response.
Pass bytes via data or a string via body.
timeoutbounds the entire request — connect, send, response, and body read. If exceeded, the underlying HttpClient is force-closed (releasing the socket immediately) and TimeoutException is thrown.package:http's top-level functions cannot do this — they construct an internalClientand give no handle to force-close.
Implementation
Future<http.Response> ajax(Uri url, {String method = "GET",
List<int>? data, String? body, Map<String, String>? headers,
Duration? timeout})
=> _ajax(url, method: method, data: data, body: body, headers: headers,
timeout: timeout, getResponse: http.Response.fromStream);