Skip to content

Update main.dart#5

Open
carrrmenleong wants to merge 5 commits into
jumper385:masterfrom
carrrmenleong:master
Open

Update main.dart#5
carrrmenleong wants to merge 5 commits into
jumper385:masterfrom
carrrmenleong:master

Conversation

@carrrmenleong

Copy link
Copy Markdown

Tried to implement function to detect internet, but didn't seems to work

@jumper385 jumper385 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wont work :/ i think you'll need to look into this a little more ngl :/
try looking at this instead...
https://pub.dev/packages/connectivity

Comment thread lib/helpers.dart
Comment thread lib/helpers.dart
Comment on lines +11 to +22
Future<bool> isConnected() async {
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.mobile) {
return (await DataConnectionChecker().hasConnection);
}
else if (connectivityResult == ConnectivityResult.wifi) {
return (await DataConnectionChecker().hasConnection);
}
else {
return false;
}
} No newline at end of file

@jumper385 jumper385 Nov 18, 2020

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try using this instead 😁

I lie... you might just be able to make do without DataConnectionChecker() and return a boolean of ConnectivityResult.none because the connectivity package checks the signal on each of the internet connection providers (mobile and wifi)

  Future<bool> isConnected() async {
    var connectivtyResult = await Connectivity().checkConnectivity();
    print(connectivtyResult != ConnectivityResult.none ? "CONNECTED" : "NOT CONNECTED");
    return connectivtyResult != ConnectivityResult.none ? true : false;
  }

@jumper385 jumper385 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main.dart isnt great :/

Comment thread pubspec.yaml
sensors: ^0.4.2+4
http: ^0.12.2
location: ^3.0.0
data_connection_checker: ^0.3.4

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove here

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

Successfully merging this pull request may close these issues.

2 participants