From e8a5cc713ed95912d0219c2032faac41641a9166 Mon Sep 17 00:00:00 2001 From: git-elliot Date: Mon, 18 Nov 2024 23:28:53 +0530 Subject: [PATCH] localInterface added --- .../host_scan_page/host_scan_bloc/host_scan_bloc.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart b/lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart index bf13747..2fe3adc 100644 --- a/lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart +++ b/lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart @@ -57,6 +57,7 @@ class HostScanBloc extends Bloc { debugPrint('Unimplemented error $e'); } ip = await info.getWifiIP(); + final interface = await NetInterface.localInterface(); if (appSettings.customSubnet.isNotEmpty) { gatewayIp = appSettings.customSubnet; debugPrint('Taking gatewayIp from appSettings: $gatewayIp'); @@ -65,11 +66,16 @@ class HostScanBloc extends Bloc { debugPrint( 'Taking gatewayIp from NetworkInfo().getWifiGatewayIP(): $gatewayIp', ); - } else { + } else if (ip != null) { // NetworkInfo().getWifiGatewayIP() is null on android 35, so fail-safe // to NetworkInfo().getWifiIP() gatewayIp = ip; debugPrint('Taking gatewayIp from NetworkInfo().getWifiIP(): $gatewayIp'); + } else if (interface != null) { + gatewayIp = interface.ipAddress; + debugPrint( + 'Taking gatewayIp from NetInterface.localInterface(): $gatewayIp', + ); } if (gatewayIp == null) { emit(const HostScanState.error());