Vanethos / flutter_connectivity_widget

A widget that shows the user if the phone is connected to the internet or not
BSD 2-Clause "Simplified" License
68 stars 34 forks source link

Banner only works with provided url not googgle, facebook, amazon ect #14

Closed liveaffiliates closed 8 months ago

liveaffiliates commented 4 years ago

Hi,

Thanks for creating this.

I am trying to implement but have run into strange behavior with the following line:

ConnectivityUtils.instance.setServerToPing("https://gist.githubusercontent.com/Vanethos/dccc4b4605fc5c5aa4b9153dacc7391c/raw/355ccc0e06d0f84fdbdc83f5b8106065539d9781/gistfile1.txt");

It works great with the address you provided but if I comment out that line I thought it would default to www.google.com but I just get no connectivity.

If I change it to google, facebook, amazon all give no connectivity like so:

  ConnectivityUtils.instance.setServerToPing("http://www.google.com");
  ConnectivityUtils.instance.setServerToPing("http://www.facebook.com");
  ConnectivityUtils.instance.setServerToPing("http://www.amazon.com");

I am not sure why only your provided text file is working. I am currently staying in Indonesia, that's all I can think.

Is there any way for me to debug whats going on?

Thanks

Vanethos commented 4 years ago

The new version will have #13 integreated, which will check for all the status codes between 200 and 399.

This might be due to the fact that some of the websites were returning 204, for example, and the library was not correctly handling them

If you can, please try with the new version (I'll upload it in a few hours)

ebot64 commented 4 years ago

Using "http://example.com/" with a callback works for me as follow:

ConnectivityUtils.initialize( serverToPing: "http://example.com/", callback: (response) => response.isNotEmpty );

This works for me.