In the IO library, there is an HttpClient class for creating HTTP requests:
import 'dart:io'; void main() { HttpClient client = new HttpClient(); client.getUrl(Uri.parse("http://www.dartlang.org/")) .then((HttpClientRequest request) { return request.close(); }) .then(HttpBodyHandler.processResponse) .then((HttpClientResponseBody body) { print(body.body); }); }
Update: Since the HttpClient is rather low level and a bit awkward for something simple like this, the main Dart team also made pub , http , which makes it easier:
import 'package:http/http.dart' as http; void main() { http.get('http://pub.dartlang.org/').then((response) { print(response.body); }); }
I found that the crypto package was dependent, so my pubspec.yaml looks like this:
name: app-name dependencies: http: any crypto: any
source share