dart - 如何基于包含 scheme+host+port 的字符串创建 URL
问题描述
我有一个包含方案+主机+端口的字符串。例如:http://192.120.123.1:4000
方案在哪里http
,主机是 192.120.123.1
,端口是4000
其他例子是:
https://stackoverflow.com/
http:localhost
http://google.com:4000
如何基于该字符串创建 Dart的Uri类的实例?
解决方案
您可以使用Uri.parse将 a 解析String
为 Uri,或使用命名参数初始化,Uri
例如:
Uri(scheme: 'https', host: 'google.com', port: 4000);
推荐阅读
- r - 因子:整数到因子
- php - 在 woocommerce 订单中删除我的过滤器
- java - 如何在java中求解正弦数学方程?
- java - 在 REST 控制器中传递枚举时,我得到 java.lang.IllegalArgumentException 而我使用枚举作为字符串
- excel - 最小化窗口驱动程序 selenium excel vba
- bash - 在 kubernetes pods 容器中循环运行命令 n 次
- django - 如何连接登录模型和帖子模型
- python - 如何使用 Python 从 BoltDB 中读取数据?
- python - 如何在 Python 中录制系统音频?(Linux)
- scikit-learn - 初学者问题:在回归模型中变换目标的效果