Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle "Network Aware" for web too along with mobile? #100

Open
pallavbohara opened this issue Aug 28, 2020 · 6 comments
Open

How to handle "Network Aware" for web too along with mobile? #100

pallavbohara opened this issue Aug 28, 2020 · 6 comments

Comments

@pallavbohara
Copy link

pallavbohara commented Aug 28, 2020

Hello FilledStacks Team,
I really love your tutorials. While following tutorial for network connectivity I found that connectivity plugin is not returning correct values for web I also tried to add connectivity_for_web. Although web is offline always. But I cannot setup for both in single code base. Please guide to do so.

Regards,
Pallav Bohara

@FilledStacks
Copy link
Owner

Hi there,

In my experience there won't be much difference. what exactly are you struggling with setting up for both?

@pallavbohara
Copy link
Author

Hello,
Thanks for quick reply.
Actually right now I am using connectivity: ^0.4.9+2 and it is returning "ConnectivityStatus.Offline" every time for web(which is I think wrong). And I think if we can check some where if it is web then just avoid connectivity check as web always will have connectivity.

@FilledStacks
Copy link
Owner

@pallavbohara sounds like an option. the constant kIsWeb tells you if it's running on web or not. You can use that for your logic.

@pallavbohara
Copy link
Author

pallavbohara commented Sep 1, 2020

Hello,
It is not working.
I am trying like this(In reference to your 'NetWork Aware Code' in connectivity_servie.dart :

ConnectivityStatus _getStatusFromResult(ConnectivityResult result) { if (kIsWeb) { return ConnectivityStatus.Cellular; } switch (result) { case ConnectivityResult.mobile: return ConnectivityStatus.Cellular; break; case ConnectivityResult.wifi: return ConnectivityStatus.Wifi; break; case ConnectivityResult.none: return ConnectivityStatus.Offline; break; default: return ConnectivityStatus.Offline; } }

But It is always picking Offline code. I am attacing whole project zip in case you need.

network_sensitive (2).zip

@pallavbohara
Copy link
Author

Hello,
It is not working.
I am trying like this(In reference to your 'NetWork Aware Code' in connectivity_servie.dart :

ConnectivityStatus _getStatusFromResult(ConnectivityResult result) { if (kIsWeb) { return ConnectivityStatus.Cellular; } switch (result) { case ConnectivityResult.mobile: return ConnectivityStatus.Cellular; break; case ConnectivityResult.wifi: return ConnectivityStatus.Wifi; break; case ConnectivityResult.none: return ConnectivityStatus.Offline; break; default: return ConnectivityStatus.Offline; } }

But It is always picking Offline code. I am attacing whole project zip in case you need.

network_sensitive (2).zip

Sorry, I have mistakenly created a new issue.

@pallavbohara pallavbohara reopened this Sep 1, 2020
@FilledStacks
Copy link
Owner

That's the constant I used, maybe if changed. there's other ways to check for web as well. I don't have it on hand right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants