一、安装
- Readme
- Changelog
- Example
- Installing
- Versions
- Scores
Use this package as a library
Depend on it
Run this command:
With Dart:
$ dart pub add http
With Flutter:
$ flutter pub add http
This will add a line like this to your package’s pubspec.yaml (and run an implicit dart pub get):
dependencies: http: ^0.13.4
Import it
Now in your Dart code, you can use:
import ‘package:http/http.dart’;
二、使用
import 'package:http/http.dart' as http;
var url = Uri.parse('https://example.com/whatsit/create');
var response = await http.post(url, body: {'name': 'doodle', 'color': 'blue'});
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
print(await http.read(Uri.parse('https://example.com/foobar.txt')));