-
Notifications
You must be signed in to change notification settings - Fork 4
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
Don't wait for logging + Cache internet connection status #853
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,14 +1,24 @@ | ||||||
import 'package:internet_connection_checker_plus/internet_connection_checker_plus.dart'; | ||||||
|
||||||
mixin NetworkInfo { | ||||||
Future<bool> get isConnected; | ||||||
bool get isConnected; | ||||||
} | ||||||
|
||||||
class NetworkInfoImpl implements NetworkInfo { | ||||||
NetworkInfoImpl(this.connectionChecker); | ||||||
NetworkInfoImpl(this.connectionChecker) { | ||||||
// First check if there is an internet connection | ||||||
connectionChecker.hasInternetAccess.then((value) { | ||||||
isConnected = value; | ||||||
}); | ||||||
|
||||||
final InternetConnection connectionChecker; | ||||||
// Listen for changes in the internet connection status | ||||||
connectionChecker.onStatusChange.listen((status) { | ||||||
isConnected = status == InternetStatus.connected; | ||||||
}); | ||||||
} | ||||||
|
||||||
@override | ||||||
Future<bool> get isConnected => connectionChecker.hasInternetAccess; | ||||||
bool isConnected = true; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid redundant initialization of The Consider initializing - bool isConnected = true;
+ bool isConnected = false; Committable suggestion
Suggested change
|
||||||
|
||||||
final InternetConnection connectionChecker; | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid redundant null check for
isConnected
.The internet connection check uses
== false
which is redundant and can be simplified.Simplify the internet connection check.
Committable suggestion