I'm trying to use Dart's http
library for making simple HTTP GET and POST requests:
import 'package:http/http.dart' as http;
import 'package:http/src/response.dart';
void main() {
String json = getSomeJSONString();
http.post(url, body: json, encoding: Encoding.getByName("UTF-8")).then(onResponse);
}
void onResponse(Response response) {
// Do something
}
When I run this through pub build
I get:
[Dart2JS on myapp-client|web/myapp_client.dart]:Building myapp-client......
[Dart2JS on myapp-client|web/myapp_client.dart]:
../../../../../sandbox/workbench/dart/dart/dart-sdk/lib/core/uri.dart:1133:17: Info: This is the method declaration.packages/http/src/utils.dart:41:42: Warning: Arguments do not match the expected parameters of 'encodeQueryComponent'.
static String encodeQueryComponent(String component) {
^^^^^^^^^^^^^^^^^^^^
[Dart2JS on myapp-client|web/myapp_client.dart]:pairs.add([Uri.encodeQueryComponent(key, encoding: encoding),
../../../../../sandbox/workbench/dart/dart/dart-sdk/lib/core/uri.dart:1133:17: Info: This is the method declaration.
static String encodeQueryComponent(String component) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Dart2JS on myapp-client|web/myapp_client.dart]:
packages/http/src/utils.dart:42:42: Warning: Arguments do not match the expected parameters of 'encodeQueryComponent'.
Uri.encodeQueryComponent(value, encoding: encoding)]));
^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Dart2JS on myapp-client|web/myapp_client.dart]:
packages/http/src/utils.dart:41:58: Warning: No named argument 'encoding' found on method.
pairs.add([Uri.encodeQueryComponent(key, encoding: encoding),
^^^^^^^^
[Dart2JS on myapp-client|web/myapp_client.dart]:
packages/http/src/utils.dart:42:60: Warning: No named argument 'encoding' found on method.
Uri.encodeQueryComponent(value, encoding: encoding)]));
^^^^^^^^
[Info in Dart2JS]:
Generated myapp-client|web/myapp_client.dart.js (246641 characters) in 0:00:09.640230
Built 14 files!
So a few questions:
- What are these warnings, and why am I getting them?
- What do I need to do to get them to go away (fix them)?
- Why do I need to include this
http
library as a dependency if it is a part of the Dart language/core?