I am trying to validate an Instagram username, that the user should enter. I want to find out whether an account with the username exists or if not. I have tried it this way:
final request = await http.get('https://www.instagram.com/$username/');
if (request.statusCode != 404) {
...
}
I also looked at a similar question: Check if instagram account name is available
The link that is mentioned in the answer:(https://www.instagram.com/username/?__a=1)
works fine in the browser
(If the username exists, it shows all the information of the account, if it doesn't it shows two brackets that are empty)
but in my code I don't get statusCode 404
I get statusCode 200
.
I also can't catch an error.
It is the same with the link from my code (https://www.instagram.com/$username/)
, I get statusCode 200
.
Is there a different way that I have not yet considered?
Thanks for your answers in advance!