Uri.http 构造函数
从授权、路径和查询创建一个新的 http URI。
示例
var uri = Uri.http('example.org', '/path', { 'q' : 'dart' });
print(uri); // http://example.org/path?q=dart
uri = Uri.http('user:password@localhost:8080', '');
print(uri); // http://user:password@localhost:8080
uri = Uri.http('example.org', 'a b');
print(uri); // http://example.org/a%20b
uri = Uri.http('example.org', '/a%2F');
print(uri); // http://example.org/a%252F
scheme 始终设置为 http。
userInfo、host 和 port 组件来自 authority 参数。如果 authority 是 null 或空,则创建的 Uri 没有授权,不能直接用作 HTTP URL,因为 HTTP URL 必须有一个非空的 host。
path 组件来自 unencodedPath 参数。传递的路径不应进行编码,因为这个构造函数会编码路径。只有 / 被认为是路径分隔符。如果省略,默认路径为空。
query 组件来自可选的 queryParameters 参数。
实现
factory Uri.http(
String authority, [
String unencodedPath,
Map<String, dynamic /*String?|Iterable<String>*/ >? queryParameters,
]) = _Uri.http;