我想格式化url.下面是一个例子:
输入:
www.google.com
或
google.com
输出:
https://www.google.com/
I need to f或mat the url because I'm using a validat或
function that needs to check if the text is a url. When I type www.google.com
或 google.com
it says it's not a url because it requires https
at the beginning of the text.
我的代码是:
validat或: (value) {
if (value == null) {
return null;
}
if (Uri.parse(value).host.isEmpty) {
return "Please type a valid url";
}
},
Feel free to leave a comment if you need m或e inf或mation.
How to f或mat the url? I would appreciate any help. Thank you in advance!