Parsing a URI to extract query parameters, with Dart

China☆狼群 提交于 2021-02-08 12:16:32

问题


I have a request in this form:

http://website/index.html?name=MyName&token=12345

Is there a way how to extract name and token from this url? There is always an option to iterate through all characters and save it that way, but I am looking for more elegant solution in Dart.


回答1:


var uri = Uri.parse('http://website/index.html?name=MyName&token=12345');
uri.queryParameters.forEach((k, v) {
   print('key: $k - value: $v');
});

key: name - value: MyName
key: token - value: 12345


来源:https://stackoverflow.com/questions/25573567/parsing-a-uri-to-extract-query-parameters-with-dart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!