is there a way to check is URL is existing or not in http request? I am working on an accounting app it should sold for many company, so in Sign in page each ueser has to add hes own domain to connect with his company api and data, my question is here if user add worng domain or typing somthing else that is not kind of URL, how can handle it? is there any way to definde that url is not working or not existing? and in postman if typing anything insted of url, it say could not sed request. no response no error nothing.
CodePudding user response:
Future _checkUrl(String url) async {
http.Response _urlResponse = await http.get(Uri.parse(url));
if (_urlResponse.statusCode == 200) {
return true;
}
else {
return false;
}
}
_checkUrl("https://stackoverf").then((value) => {
print(value)
});