Skip to content

Commit

Permalink
Fix issue that getting the ip of the wifi failures on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanhoujun committed Mar 31, 2022
1 parent c7db216 commit c75ab41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/enter/view/enter_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,13 @@ class _EnterState extends State<EnterPage>
String deviceName = "";

NetworkInfo networkInfo = NetworkInfo();
String? ip = await networkInfo.getWifiIP() ?? "*.*.*.*";
String ip = "*.*.*.*";

try {
ip = await networkInfo.getWifiIP() ?? "*.*.*.*";
} catch (e) {
log("EnterPage: get wifi ip failure! ${e.toString()}");
}
int platform = Device.PLATFORM_MACOS;

if (Platform.isMacOS) {
Expand Down
7 changes: 6 additions & 1 deletion lib/network/heartbeat_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ class HeartbeatClientImpl extends HeartbeatClient {
});

NetworkInfo networkInfo = NetworkInfo();
String currentIp = await networkInfo.getWifiIP() ?? "Unknown ip";
String currentIp = "Unknown ip";
try {
currentIp = await networkInfo.getWifiIP() ?? "Unknown ip";
} catch (e) {
log("HeartClient: get wifi ip failure: ${e.toString()}");
}
_lastHeartbeat = Heartbeat(currentIp, 0, _currentTimeInMills());
_sendToServer(_lastHeartbeat!);

Expand Down

0 comments on commit c75ab41

Please sign in to comment.