Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

flutter: httpclient method

### Method of HttpClient in flutter

request() async {
  try {
    HttpClient httpClient = HttpClient();
    HttpClientRequest request = await httpClient
        .getUrl(Uri.parse('https://jsonplaceholder.typicode.com/posts/1'));

    request.headers.add('token', 'secureTokenString');
    HttpClientResponse response = await request.close();

    var text = await response.transform(utf8.decoder).join();
    httpClient.close();
    debugPrint(text);
  } catch (e) {
    debugPrint('Failure ... : $e');
  }
}
 
PREVIOUS NEXT
Tagged: #httpclient #method
ADD COMMENT
Topic
Name
1+3 =