diff --git a/.github/workflows/network_info_plus.yaml b/.github/workflows/network_info_plus.yaml index c7db207e88..f4caae9d41 100644 --- a/.github/workflows/network_info_plus.yaml +++ b/.github/workflows/network_info_plus.yaml @@ -178,7 +178,6 @@ jobs: run: ./.github/workflows/scripts/build-examples.sh windows ./lib/main.dart windows_integration_test: - if: false # TODO: reinstate this when the windows implementation is fixed runs-on: windows-latest timeout-minutes: 30 steps: diff --git a/packages/network_info_plus/network_info_plus/README.md b/packages/network_info_plus/network_info_plus/README.md index db31ba8a68..50a957c2f5 100644 --- a/packages/network_info_plus/network_info_plus/README.md +++ b/packages/network_info_plus/network_info_plus/README.md @@ -19,10 +19,10 @@ The functionality is not supported on Web. ## Requirements -- Flutter >=3.3.0 -- Dart >=2.18.0 <4.0.0 -- iOS >=12.0 -- macOS >=10.14 +- Flutter >=3.41.0 +- Dart >=3.11.0 <4.0.0 +- iOS >=13.0 +- macOS >=10.15 - Java 17 - Kotlin 2.2.0 - Android Gradle Plugin >=8.12.1 diff --git a/packages/network_info_plus/network_info_plus/lib/src/network_info_plus_linux.dart b/packages/network_info_plus/network_info_plus/lib/src/network_info_plus_linux.dart index b4bf1211c0..92f2314729 100644 --- a/packages/network_info_plus/network_info_plus/lib/src/network_info_plus_linux.dart +++ b/packages/network_info_plus/network_info_plus/lib/src/network_info_plus_linux.dart @@ -9,8 +9,8 @@ import 'package:nm/nm.dart'; // ignore_for_file: public_member_api_docs typedef _DeviceGetter = Future Function(NetworkManagerDevice? device); -typedef _ConnectionGetter = Future Function( - NetworkManagerActiveConnection? connection); +typedef _ConnectionGetter = + Future Function(NetworkManagerActiveConnection? connection); @visibleForTesting typedef NetworkManagerClientFactory = NetworkManagerClient Function(); @@ -76,8 +76,9 @@ class NetworkInfoPlusLinuxPlugin extends NetworkInfoPlatform { Future _getDeviceValue(_DeviceGetter getter) { return _getConnectionValue((connection) { - final device = connection?.devices - .firstWhereOrNull((device) => device.wireless != null); + final device = connection?.devices.firstWhereOrNull( + (device) => device.wireless != null, + ); return getter(device); }); } diff --git a/packages/network_info_plus/network_info_plus/lib/src/network_info_plus_windows.dart b/packages/network_info_plus/network_info_plus/lib/src/network_info_plus_windows.dart index afbe00d437..870f85028c 100644 --- a/packages/network_info_plus/network_info_plus/lib/src/network_info_plus_windows.dart +++ b/packages/network_info_plus/network_info_plus/lib/src/network_info_plus_windows.dart @@ -1,5 +1,5 @@ /// The Windows implementation of `network_info_plus`. -library network_info_plus_windows; +library; import 'dart:ffi'; @@ -7,37 +7,36 @@ import 'package:ffi/ffi.dart'; import 'package:network_info_plus/src/windows_structs.dart'; import 'package:win32/win32.dart'; import 'package:network_info_plus_platform_interface/network_info_plus_platform_interface.dart'; -import 'package:win32/winsock2.dart'; -typedef WlanQuery = String? Function( - Pointer pGuid, - Pointer pAttributes, -); +typedef WlanQuery = + String? Function( + Pointer pGuid, + Pointer pAttributes, + ); class NetworkInfoPlusWindowsPlugin extends NetworkInfoPlatform { - int clientHandle = NULL; + HANDLE clientHandle = HANDLE(nullptr); static void registerWith() { NetworkInfoPlatform.instance = NetworkInfoPlusWindowsPlugin(); } void openHandle() { - if (clientHandle != NULL) return; + if (clientHandle.isValid) return; // ignore: constant_identifier_names const WLAN_API_VERSION_2_0 = 0x00000002; - final phClientHandle = calloc(); + final phClientHandle = calloc(); final pdwNegotiatedVersion = calloc(); try { final hr = WlanOpenHandle( WLAN_API_VERSION_2_0, - nullptr, pdwNegotiatedVersion, phClientHandle, ); if (hr == ERROR_SERVICE_NOT_ACTIVE) return; - clientHandle = phClientHandle.value; + clientHandle = HANDLE(phClientHandle.value); } finally { free(pdwNegotiatedVersion); free(phClientHandle); @@ -45,10 +44,10 @@ class NetworkInfoPlusWindowsPlugin extends NetworkInfoPlatform { } void closeHandle() { - if (clientHandle != NULL) { - WlanCloseHandle(clientHandle, nullptr); + if (clientHandle.isValid) { + WlanCloseHandle(clientHandle); - clientHandle = NULL; + clientHandle = HANDLE(nullptr); } } @@ -57,17 +56,20 @@ class NetworkInfoPlusWindowsPlugin extends NetworkInfoPlatform { final ppInterfaceList = calloc>(); try { - var hr = WlanEnumInterfaces(clientHandle, nullptr, ppInterfaceList); + var hr = WlanEnumInterfaces(clientHandle, ppInterfaceList); if (hr != ERROR_SUCCESS) { return null; // no wifi interface available } for (var i = 0; i < ppInterfaceList.value.ref.dwNumberOfItems; i++) { final pInterfaceGuid = calloc() - ..ref.setGUID(ppInterfaceList.value.ref.InterfaceInfo[i].InterfaceGuid - .toString()); + ..ref.setGUID( + ppInterfaceList.value.ref.InterfaceInfo[i].InterfaceGuid.toString(), + ); - const opCode = 7; // wlan_intf_opcode_current_connection + const opCode = WLAN_INTF_OPCODE( + 7, + ); // wlan_intf_opcode_current_connection final pdwDataSize = calloc(); final ppAttributes = calloc>(); @@ -76,13 +78,13 @@ class NetworkInfoPlusWindowsPlugin extends NetworkInfoPlatform { clientHandle, pInterfaceGuid, opCode, - nullptr, pdwDataSize, ppAttributes.cast(), - nullptr, + null, ); if (hr != ERROR_SUCCESS) break; - if (ppAttributes.value.ref.isState != 0) { + if (ppAttributes.value.ref.isState != + wlan_interface_state_not_ready) { return query(pInterfaceGuid, ppAttributes.value); } } finally { @@ -105,7 +107,7 @@ class NetworkInfoPlusWindowsPlugin extends NetworkInfoPlatform { bssid.map((e) => e.toRadixString(16).padLeft(2, '0')).join(':'); String formatIPAddress(Pointer addr) { - final buffer = calloc(64).cast(); + final buffer = PSTR(calloc(64).cast()); try { if (addr.ref.sa_family == AF_INET) { final sinAddr = addr.cast().ref.sin_addr; @@ -122,17 +124,19 @@ class NetworkInfoPlusWindowsPlugin extends NetworkInfoPlatform { inet_ntop(AF_INET6, sinAddrPtr, buffer, 64); free(sinAddrPtr); } - return buffer.cast().toDartString(); + return buffer.toDartString(); } finally { free(buffer); } } - Pointer? getAdapterAddress(Pointer pGuid, - Pointer pIpAdapterAddresses) { + Pointer? getAdapterAddress( + Pointer pGuid, + Pointer pIpAdapterAddresses, + ) { final ifLuid = calloc(); try { - if (ConvertInterfaceGuidToLuid(pGuid, ifLuid) != NO_ERROR) { + if (ConvertInterfaceGuidToLuid(pGuid, ifLuid).isError) { return null; } @@ -151,51 +155,74 @@ class NetworkInfoPlusWindowsPlugin extends NetworkInfoPlatform { @override Future getWifiName() { - return Future.value(query((pGuid, pAttributes) { - final DOT11_SSID ssid = - pAttributes.ref.wlanAssociationAttributes.dot11Ssid; - final charCodes = []; - for (var i = 0; i < ssid.uSSIDLength; i++) { - if (ssid.ucSSID[i] == 0x00) break; - charCodes.add(ssid.ucSSID[i]); - } - return String.fromCharCodes(charCodes); - })); + return Future.value( + query((pGuid, pAttributes) { + final DOT11_SSID ssid = + pAttributes.ref.wlanAssociationAttributes.dot11Ssid; + final charCodes = []; + for (var i = 0; i < ssid.uSSIDLength; i++) { + if (ssid.ucSSID[i] == 0x00) break; + charCodes.add(ssid.ucSSID[i]); + } + return String.fromCharCodes(charCodes); + }), + ); } /// Obtains the wifi BSSID of the connected network. @override Future getWifiBSSID() { - return Future.value(query((pGuid, pAttributes) { - return formatBssid([ - pAttributes.ref.wlanAssociationAttributes.dot11Bssid[0], - pAttributes.ref.wlanAssociationAttributes.dot11Bssid[1], - pAttributes.ref.wlanAssociationAttributes.dot11Bssid[2], - pAttributes.ref.wlanAssociationAttributes.dot11Bssid[3], - pAttributes.ref.wlanAssociationAttributes.dot11Bssid[4], - pAttributes.ref.wlanAssociationAttributes.dot11Bssid[5], - ]); - })); + return Future.value( + query((pGuid, pAttributes) { + return formatBssid([ + pAttributes.ref.wlanAssociationAttributes.dot11Bssid[0], + pAttributes.ref.wlanAssociationAttributes.dot11Bssid[1], + pAttributes.ref.wlanAssociationAttributes.dot11Bssid[2], + pAttributes.ref.wlanAssociationAttributes.dot11Bssid[3], + pAttributes.ref.wlanAssociationAttributes.dot11Bssid[4], + pAttributes.ref.wlanAssociationAttributes.dot11Bssid[5], + ]); + }), + ); } Future getIPAddr(int family) { - return Future.value(query((pGuid, pAttributes) { - final ulSize = calloc(); - Pointer pIpAdapterAddress = nullptr; - try { - GetAdaptersAddresses(family, 0, nullptr, nullptr, ulSize); - pIpAdapterAddress = HeapAlloc(GetProcessHeap(), 0, ulSize.value).cast(); - GetAdaptersAddresses(family, 0, nullptr, pIpAdapterAddress, ulSize); - final pAddr = getAdapterAddress(pGuid, pIpAdapterAddress); - if (pAddr == null) return null; - if (pAddr.ref.FirstUnicastAddress == nullptr) return null; - return formatIPAddress( - pAddr.ref.FirstUnicastAddress.ref.Address.lpSockaddr); - } finally { - free(ulSize); - if (pIpAdapterAddress != nullptr) free(pIpAdapterAddress); - } - })); + return Future.value( + query((pGuid, pAttributes) { + final ulSize = calloc(); + Pointer? pIpAdapterAddress; + try { + GetAdaptersAddresses( + family, + GET_ADAPTERS_ADDRESSES_FLAGS(0), + null, + ulSize, + ); + pIpAdapterAddress = HeapAlloc( + GetProcessHeap().value, + HEAP_FLAGS(0), + ulSize.value, + ).cast(); + GetAdaptersAddresses( + family, + GET_ADAPTERS_ADDRESSES_FLAGS(0), + pIpAdapterAddress, + ulSize, + ); + final pAddr = getAdapterAddress(pGuid, pIpAdapterAddress); + if (pAddr == null) return null; + if (pAddr.ref.FirstUnicastAddress == nullptr) return null; + return formatIPAddress( + pAddr.ref.FirstUnicastAddress.ref.Address.lpSockaddr, + ); + } finally { + free(ulSize); + if (pIpAdapterAddress != null && pIpAdapterAddress != nullptr) { + free(pIpAdapterAddress); + } + } + }), + ); } /// Obtains the IP v4 address of the connected wifi network @@ -213,33 +240,39 @@ class NetworkInfoPlusWindowsPlugin extends NetworkInfoPlatform { /// Obtains the subnet mask of the connected wifi network @override Future getWifiSubmask() { - return Future.value(query((pGuid, pAttributes) { - final ulSize = calloc(); - Pointer pIpAdapterAddress = nullptr; - try { - GetAdaptersAddresses( - AF_INET, - 0, - nullptr, - nullptr, - ulSize, - ); - pIpAdapterAddress = HeapAlloc(GetProcessHeap(), 0, ulSize.value).cast(); - GetAdaptersAddresses( - AF_INET, - 0, - nullptr, - pIpAdapterAddress, - ulSize, - ); - final pAddr = getAdapterAddress(pGuid, pIpAdapterAddress); - if (pAddr == null) return null; - return extractSubnet(pAddr); - } finally { - free(ulSize); - if (pIpAdapterAddress != nullptr) free(pIpAdapterAddress); - } - })); + return Future.value( + query((pGuid, pAttributes) { + final ulSize = calloc(); + Pointer? pIpAdapterAddress; + try { + GetAdaptersAddresses( + AF_INET, + GET_ADAPTERS_ADDRESSES_FLAGS(0), + null, + ulSize, + ); + pIpAdapterAddress = HeapAlloc( + GetProcessHeap().value, + HEAP_FLAGS(0), + ulSize.value, + ).cast(); + GetAdaptersAddresses( + AF_INET, + GET_ADAPTERS_ADDRESSES_FLAGS(0), + pIpAdapterAddress, + ulSize, + ); + final pAddr = getAdapterAddress(pGuid, pIpAdapterAddress); + if (pAddr == null) return null; + return extractSubnet(pAddr); + } finally { + free(ulSize); + if (pIpAdapterAddress != null && pIpAdapterAddress != nullptr) { + free(pIpAdapterAddress); + } + } + }), + ); } String extractSubnet(Pointer pIpAdapterAddress) { @@ -285,34 +318,41 @@ class NetworkInfoPlusWindowsPlugin extends NetworkInfoPlatform { /// This is the IP address of the router @override Future getWifiGatewayIP() { - return Future.value(query((pGuid, pAttributes) { - final ulSize = calloc(); - Pointer pIpAdapterAddress = nullptr; - try { - GetAdaptersAddresses( - AF_INET, - 0x80, - nullptr, - nullptr, - ulSize, - ); - pIpAdapterAddress = HeapAlloc(GetProcessHeap(), 0, ulSize.value).cast(); - GetAdaptersAddresses( - AF_INET, - 0x80, - nullptr, - pIpAdapterAddress, - ulSize, - ); - final pAddr = getAdapterAddress(pGuid, pIpAdapterAddress); - if (pAddr == null) return null; - if (pAddr.ref.FirstGatewayAddress == nullptr) return null; - return formatIPAddress( - pAddr.ref.FirstGatewayAddress.ref.Address.lpSockaddr); - } finally { - free(ulSize); - if (pIpAdapterAddress != nullptr) free(pIpAdapterAddress); - } - })); + return Future.value( + query((pGuid, pAttributes) { + final ulSize = calloc(); + Pointer? pIpAdapterAddress; + try { + GetAdaptersAddresses( + AF_INET, + GET_ADAPTERS_ADDRESSES_FLAGS(0x80), + null, + ulSize, + ); + pIpAdapterAddress = HeapAlloc( + GetProcessHeap().value, + HEAP_FLAGS(0), + ulSize.value, + ).cast(); + GetAdaptersAddresses( + AF_INET, + GET_ADAPTERS_ADDRESSES_FLAGS(0x80), + pIpAdapterAddress, + ulSize, + ); + final pAddr = getAdapterAddress(pGuid, pIpAdapterAddress); + if (pAddr == null) return null; + if (pAddr.ref.FirstGatewayAddress == nullptr) return null; + return formatIPAddress( + pAddr.ref.FirstGatewayAddress.ref.Address.lpSockaddr, + ); + } finally { + free(ulSize); + if (pIpAdapterAddress != null && pIpAdapterAddress != nullptr) { + free(pIpAdapterAddress); + } + } + }), + ); } } diff --git a/packages/network_info_plus/network_info_plus/lib/src/windows_structs.dart b/packages/network_info_plus/network_info_plus/lib/src/windows_structs.dart index b349b82c98..f7e47c7560 100644 --- a/packages/network_info_plus/network_info_plus/lib/src/windows_structs.dart +++ b/packages/network_info_plus/network_info_plus/lib/src/windows_structs.dart @@ -7,7 +7,7 @@ import 'dart:ffi'; /// The SOCKADDR_IN structure specifies a transport address and port for the AF_INET address family. /// /// {@category struct} -class SOCKADDR_IN extends Struct { +base class SOCKADDR_IN extends Struct { @Uint16() external int sin_family; @@ -24,7 +24,7 @@ class SOCKADDR_IN extends Struct { /// The SOCKADDR_IN6 structure specifies a transport address and port for the AF_INET6 address family. /// /// {@category struct} -class SOCKADDR_IN6 extends Struct { +base class SOCKADDR_IN6 extends Struct { @Uint16() external int sin6_family; diff --git a/packages/network_info_plus/network_info_plus/pubspec.yaml b/packages/network_info_plus/network_info_plus/pubspec.yaml index 9fdb31315d..4b28fff9e0 100644 --- a/packages/network_info_plus/network_info_plus/pubspec.yaml +++ b/packages/network_info_plus/network_info_plus/pubspec.yaml @@ -10,8 +10,8 @@ topics: - utils environment: - sdk: ">=2.18.0 <4.0.0" - flutter: ">=3.3.0" + sdk: ">=3.11.0 <4.0.0" + flutter: ">=3.41.0" flutter: plugin: @@ -32,20 +32,20 @@ flutter: fileName: src/network_info_plus_web.dart dependencies: - collection: ^1.17.0 - nm: ^0.5.0 + collection: ^1.19.1 + ffi: ^2.2.0 flutter: sdk: flutter flutter_web_plugins: sdk: flutter - meta: ^1.8.0 + meta: ^1.17.0 network_info_plus_platform_interface: ^2.0.2 - win32: ^5.5.3 - ffi: ^2.0.1 + nm: ^0.5.0 + win32: ^6.0.0 dev_dependencies: + flutter_lints: ^6.0.0 flutter_test: sdk: flutter - mockito: ^5.4.0 - plugin_platform_interface: ^2.1.4 - flutter_lints: ">=4.0.0 <6.0.0" + mockito: ^5.6.4 + plugin_platform_interface: ^2.1.8 diff --git a/packages/network_info_plus/network_info_plus/test/network_info_plus_linux_test.dart b/packages/network_info_plus/network_info_plus/test/network_info_plus_linux_test.dart index aea777e13a..dc5ab1195a 100644 --- a/packages/network_info_plus/network_info_plus/test/network_info_plus_linux_test.dart +++ b/packages/network_info_plus/network_info_plus/test/network_info_plus_linux_test.dart @@ -1,5 +1,5 @@ @TestOn('linux') -library network_info_plus_linux_test; +library; import 'package:flutter_test/flutter_test.dart'; import 'package:network_info_plus/network_info_plus.dart'; diff --git a/packages/network_info_plus/network_info_plus/test/network_info_plus_windows_test.dart b/packages/network_info_plus/network_info_plus/test/network_info_plus_windows_test.dart index d8032a5531..d47307e1c5 100644 --- a/packages/network_info_plus/network_info_plus/test/network_info_plus_windows_test.dart +++ b/packages/network_info_plus/network_info_plus/test/network_info_plus_windows_test.dart @@ -1,5 +1,5 @@ @TestOn('windows') -library device_info_plus_windows_test; +library; import 'package:flutter_test/flutter_test.dart'; import 'package:network_info_plus/network_info_plus.dart'; @@ -27,8 +27,10 @@ void main() { final plugin = NetworkInfoPlusWindowsPlugin(); final ipAddress = await plugin.getWifiIP(); expect( - ipAddress, - matches( - r'^(?=\d+\.\d+\.\d+\.\d+$)(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\.?){4}$')); + ipAddress, + matches( + r'^(?=\d+\.\d+\.\d+\.\d+$)(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\.?){4}$', + ), + ); }); } diff --git a/packages/network_info_plus/network_info_plus_platform_interface/lib/method_channel_network_info.dart b/packages/network_info_plus/network_info_plus_platform_interface/lib/method_channel_network_info.dart index 8c5c6b5253..58ca7a8d36 100644 --- a/packages/network_info_plus/network_info_plus_platform_interface/lib/method_channel_network_info.dart +++ b/packages/network_info_plus/network_info_plus_platform_interface/lib/method_channel_network_info.dart @@ -12,8 +12,9 @@ import 'package:meta/meta.dart'; class MethodChannelNetworkInfo extends NetworkInfoPlatform { /// The method channel used to interact with the native platform. @visibleForTesting - MethodChannel methodChannel = - const MethodChannel('dev.fluttercommunity.plus/network_info'); + MethodChannel methodChannel = const MethodChannel( + 'dev.fluttercommunity.plus/network_info', + ); @override Future getWifiName() async { diff --git a/packages/network_info_plus/network_info_plus_platform_interface/lib/src/enums.dart b/packages/network_info_plus/network_info_plus_platform_interface/lib/src/enums.dart index 8cd7abaf25..9b2323444c 100644 --- a/packages/network_info_plus/network_info_plus_platform_interface/lib/src/enums.dart +++ b/packages/network_info_plus/network_info_plus_platform_interface/lib/src/enums.dart @@ -16,5 +16,5 @@ enum LocationAuthorizationStatus { authorizedWhenInUse, /// Status unknown. - unknown + unknown, } diff --git a/packages/network_info_plus/network_info_plus_platform_interface/pubspec.yaml b/packages/network_info_plus/network_info_plus_platform_interface/pubspec.yaml index 13217ff627..0501dc2963 100644 --- a/packages/network_info_plus/network_info_plus_platform_interface/pubspec.yaml +++ b/packages/network_info_plus/network_info_plus_platform_interface/pubspec.yaml @@ -5,16 +5,16 @@ homepage: https://github.com/fluttercommunity/plus_plugins repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/ environment: - sdk: ">=2.18.0 <4.0.0" - flutter: ">=3.3.0" + sdk: ">=3.11.0 <4.0.0" + flutter: ">=3.41.0" dependencies: flutter: sdk: flutter - meta: ^1.8.0 - plugin_platform_interface: ^2.1.4 + meta: ^1.17.0 + plugin_platform_interface: ^2.1.8 dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ">=4.0.0 <6.0.0" + flutter_lints: ^6.0.0 diff --git a/packages/network_info_plus/network_info_plus_platform_interface/test/method_channel_network_info_test.dart b/packages/network_info_plus/network_info_plus_platform_interface/test/method_channel_network_info_test.dart index 4cd4d12525..13c188537c 100644 --- a/packages/network_info_plus/network_info_plus_platform_interface/test/method_channel_network_info_test.dart +++ b/packages/network_info_plus/network_info_plus_platform_interface/test/method_channel_network_info_test.dart @@ -17,133 +17,78 @@ void main() { methodChannelNetworkInfo = MethodChannelNetworkInfo(); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler( - methodChannelNetworkInfo.methodChannel, - (MethodCall methodCall) async { - log.add(methodCall); - switch (methodCall.method) { - case 'wifiName': - return '1337wifi'; - case 'wifiBSSID': - return 'c0:ff:33:c0:d3:55'; - case 'wifiIPAddress': - return '127.0.0.1'; - case 'wifiIPv6Address': - return '2002:7f00:0001:0:0:0:0:0'; - case 'wifiBroadcast': - return '127.0.0.255'; - case 'wifiGatewayAddress': - return '127.0.0.0'; - case 'wifiSubmask': - return '255.255.255.0'; - case 'requestLocationServiceAuthorization': - return 'authorizedAlways'; - case 'getLocationServiceAuthorization': - return 'authorizedAlways'; - default: - return null; - } - }, - ); + .setMockMethodCallHandler(methodChannelNetworkInfo.methodChannel, ( + MethodCall methodCall, + ) async { + log.add(methodCall); + switch (methodCall.method) { + case 'wifiName': + return '1337wifi'; + case 'wifiBSSID': + return 'c0:ff:33:c0:d3:55'; + case 'wifiIPAddress': + return '127.0.0.1'; + case 'wifiIPv6Address': + return '2002:7f00:0001:0:0:0:0:0'; + case 'wifiBroadcast': + return '127.0.0.255'; + case 'wifiGatewayAddress': + return '127.0.0.0'; + case 'wifiSubmask': + return '255.255.255.0'; + case 'requestLocationServiceAuthorization': + return 'authorizedAlways'; + case 'getLocationServiceAuthorization': + return 'authorizedAlways'; + default: + return null; + } + }); log.clear(); }); test('getWifiName', () async { final result = await methodChannelNetworkInfo.getWifiName(); expect(result, '1337wifi'); - expect( - log, - [ - isMethodCall( - 'wifiName', - arguments: null, - ), - ], - ); + expect(log, [isMethodCall('wifiName', arguments: null)]); }); test('getWifiBSSID', () async { final result = await methodChannelNetworkInfo.getWifiBSSID(); expect(result, 'c0:ff:33:c0:d3:55'); - expect( - log, - [ - isMethodCall( - 'wifiBSSID', - arguments: null, - ), - ], - ); + expect(log, [isMethodCall('wifiBSSID', arguments: null)]); }); test('getWifiIP', () async { final result = await methodChannelNetworkInfo.getWifiIP(); expect(result, '127.0.0.1'); - expect( - log, - [ - isMethodCall( - 'wifiIPAddress', - arguments: null, - ), - ], - ); + expect(log, [isMethodCall('wifiIPAddress', arguments: null)]); }); test('getWifiIPv6', () async { final result = await methodChannelNetworkInfo.getWifiIPv6(); expect(result, '2002:7f00:0001:0:0:0:0:0'); - expect( - log, - [ - isMethodCall( - 'wifiIPv6Address', - arguments: null, - ), - ], - ); + expect(log, [isMethodCall('wifiIPv6Address', arguments: null)]); }); test('getWifiBroadcast', () async { final result = await methodChannelNetworkInfo.getWifiBroadcast(); expect(result, '127.0.0.255'); - expect( - log, - [ - isMethodCall( - 'wifiBroadcast', - arguments: null, - ), - ], - ); + expect(log, [isMethodCall('wifiBroadcast', arguments: null)]); }); test('getWifiGatewayIP', () async { final result = await methodChannelNetworkInfo.getWifiGatewayIP(); expect(result, '127.0.0.0'); - expect( - log, - [ - isMethodCall( - 'wifiGatewayAddress', - arguments: null, - ), - ], - ); + expect(log, [ + isMethodCall('wifiGatewayAddress', arguments: null), + ]); }); test('getWifiSubmask', () async { final result = await methodChannelNetworkInfo.getWifiSubmask(); expect(result, '255.255.255.0'); - expect( - log, - [ - isMethodCall( - 'wifiSubmask', - arguments: null, - ), - ], - ); + expect(log, [isMethodCall('wifiSubmask', arguments: null)]); }); }); }