Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('NetworkInfo test driver', () {
NetworkInfo _networkInfo;
NetworkInfo networkInfo;

setUpAll(() async {
_networkInfo = NetworkInfo();
networkInfo = NetworkInfo();
});

testWidgets('test location methods, iOS only', (WidgetTester tester) async {
if (Platform.isIOS) {
expect((await _networkInfo.getLocationServiceAuthorization()),
expect((await networkInfo.getLocationServiceAuthorization()),
LocationAuthorizationStatus.notDetermined);
}
}, skip: !Platform.isIOS);

testWidgets('test non-null network value', (WidgetTester tester) async {
expect(_networkInfo.getWifiName(), isNotNull);
expect(_networkInfo.getWifiBSSID(), isNotNull);
expect(_networkInfo.getWifiIP(), isNotNull);
expect(_networkInfo.getWifiIPv6(), isNotNull);
expect(_networkInfo.getWifiSubmask(), isNotNull);
expect(_networkInfo.getWifiGatewayIP(), isNotNull);
expect(_networkInfo.getWifiBroadcast(), isNotNull);
expect(networkInfo.getWifiName(), isNotNull);
expect(networkInfo.getWifiBSSID(), isNotNull);
expect(networkInfo.getWifiIP(), isNotNull);
expect(networkInfo.getWifiIPv6(), isNotNull);
expect(networkInfo.getWifiSubmask(), isNotNull);
expect(networkInfo.getWifiGatewayIP(), isNotNull);
expect(networkInfo.getWifiBroadcast(), isNotNull);
});
});
}
27 changes: 14 additions & 13 deletions packages/network_info_plus/network_info_plus/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import 'dart:async';
import 'dart:developer' as developer;
import 'dart:io';

import 'package:network_info_plus/network_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:network_info_plus/network_info_plus.dart';

// Sets a platform override for desktop to avoid exceptions. See
// https://flutter.dev/desktop#target-platform-override for more info.
Expand Down Expand Up @@ -48,7 +48,7 @@ class MyHomePage extends StatefulWidget {
final String? title;

@override
_MyHomePageState createState() => _MyHomePageState();
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
Expand Down Expand Up @@ -142,40 +142,41 @@ class _MyHomePageState extends State<MyHomePage> {
}

try {
wifiIPv6 = await _networkInfo.getWifiIPv6();
if (!Platform.isWindows) {
wifiIPv6 = await _networkInfo.getWifiIPv6();
}
} on PlatformException catch (e) {
developer.log('Failed to get Wifi IPv6', error: e);
wifiIPv6 = 'Failed to get Wifi IPv6';
}

try {
wifiSubmask = await _networkInfo.getWifiSubmask();
if (!Platform.isWindows) {
wifiSubmask = await _networkInfo.getWifiSubmask();
}
} on PlatformException catch (e) {
developer.log('Failed to get Wifi submask address', error: e);
wifiSubmask = 'Failed to get Wifi submask address';
}

try {
wifiBroadcast = await _networkInfo.getWifiBroadcast();
if (!Platform.isWindows) {
wifiBroadcast = await _networkInfo.getWifiBroadcast();
}
} on PlatformException catch (e) {
developer.log('Failed to get Wifi broadcast', error: e);
wifiBroadcast = 'Failed to get Wifi broadcast';
}

try {
wifiGatewayIP = await _networkInfo.getWifiGatewayIP();
if (!Platform.isWindows) {
wifiGatewayIP = await _networkInfo.getWifiGatewayIP();
}
} on PlatformException catch (e) {
developer.log('Failed to get Wifi gateway address', error: e);
wifiGatewayIP = 'Failed to get Wifi gateway address';
}

try {
wifiSubmask = await _networkInfo.getWifiSubmask();
} on PlatformException catch (e) {
developer.log('Failed to get Wifi submask', error: e);
wifiSubmask = 'Failed to get Wifi submask';
}

setState(() {
_connectionStatus = 'Wifi Name: $wifiName\n'
'Wifi BSSID: $wifiBSSID\n'
Expand Down
12 changes: 2 additions & 10 deletions packages/network_info_plus/network_info_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,16 @@ dependencies:
path: ../

dependency_overrides:
network_info_plus_linux:
path: ../../network_info_plus_linux
network_info_plus_macos:
path: ../../network_info_plus_macos
network_info_plus_platform_interface:
path: ../../network_info_plus_platform_interface
network_info_plus_web:
path: ../../network_info_plus_web
network_info_plus_windows:
path: ../../network_info_plus_windows

dev_dependencies:
flutter_driver:
sdk: flutter
integration_test:
sdk: flutter
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
test: ^1.16.4
flutter_lints: ^2.0.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import 'package:network_info_plus_platform_interface/network_info_plus_platform_
export 'package:network_info_plus_platform_interface/network_info_plus_platform_interface.dart'
show LocationAuthorizationStatus;

export 'src/network_info_plus_linux.dart';

/// Discover network info: check WI-FI details and more.
class NetworkInfo {
/// Constructs a singleton instance of [NetworkInfo].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';

import 'package:collection/collection.dart';
import 'package:network_info_plus_platform_interface/network_info_plus_platform_interface.dart';
import 'package:meta/meta.dart';
import 'package:network_info_plus_platform_interface/network_info_plus_platform_interface.dart';
import 'package:nm/nm.dart';

// Used internally
Expand All @@ -16,10 +16,10 @@ typedef _ConnectionGetter = Future<String?> Function(
typedef NetworkManagerClientFactory = NetworkManagerClient Function();

/// The Linux implementation of NetworkInfoPlatform.
class NetworkInfoLinux extends NetworkInfoPlatform {
class NetworkInfoPlusLinuxPlugin extends NetworkInfoPlatform {
/// Register this dart class as the platform implementation for linux
static void registerWith() {
NetworkInfoPlatform.instance = NetworkInfoLinux();
NetworkInfoPlatform.instance = NetworkInfoPlusLinuxPlugin();
}

/// Obtains the wifi name (SSID) of the connected network
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:network_info_plus_platform_interface/network_info_plus_platform_interface.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:network_info_plus_platform_interface/network_info_plus_platform_interface.dart';

/// A stub implementation of the NetworkInfoPlatform interface for Web.
class NetworkInfoPlusPlugin extends NetworkInfoPlatform {
class NetworkInfoPlusWebPlugin extends NetworkInfoPlatform {
/// Factory method that initializes the network info plugin platform with
/// an instance of the plugin for the web.
static void registerWith(Registrar registrar) {
NetworkInfoPlatform.instance = NetworkInfoPlusPlugin();
NetworkInfoPlatform.instance = NetworkInfoPlusWebPlugin();
}

/// Obtains the wifi name (SSID) of the connected network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Pod::Spec.new do |s|
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'FlutterMacOS'

s.platform = :osx
s.osx.deployment_target = '10.11'
Expand Down
17 changes: 9 additions & 8 deletions packages/network_info_plus/network_info_plus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ flutter:
ios:
pluginClass: FLTNetworkInfoPlusPlugin
linux:
default_package: network_info_plus_linux
dartPluginClass: NetworkInfoPlusLinuxPlugin
macos:
default_package: network_info_plus_macos
pluginClass: NetworkInfoPlusPlugin
windows:
default_package: network_info_plus_windows
pluginClass: NetworkInfoPlusWindowsPlugin
web:
default_package: network_info_plus_web
pluginClass: NetworkInfoPlusWebPlugin
fileName: src/network_info_plus_web.dart

dependencies:
collection: ^1.15.0
nm: ^0.5.0
flutter:
sdk: flutter
flutter_web_plugins:
sdk: flutter
meta: ^1.8.0
network_info_plus_platform_interface: ^1.1.2
network_info_plus_linux: ^1.1.2
network_info_plus_macos: ^1.3.0
network_info_plus_windows: ^1.0.2
network_info_plus_web: ^1.0.1

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:network_info_plus_linux/src/network_info.dart';
import 'package:network_info_plus/network_info_plus.dart';
import 'package:network_info_plus_platform_interface/network_info_plus_platform_interface.dart';

void main() {
test('registered instance', () {
NetworkInfoLinux.registerWith();
expect(NetworkInfoPlatform.instance, isA<NetworkInfoLinux>());
NetworkInfoPlusLinuxPlugin.registerWith();
expect(NetworkInfoPlatform.instance, isA<NetworkInfoPlusLinuxPlugin>());
});
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.15)
set(PROJECT_NAME "network_info_plus_windows")
set(PROJECT_NAME "network_info_plus")
project(${PROJECT_NAME} LANGUAGES CXX)

set(PLUGIN_NAME "network_info_plus_windows_plugin")
set(PLUGIN_NAME "network_info_plus_plugin")

add_library(${PLUGIN_NAME} SHARED
"network_info.cpp"
"network_info_plus_windows_plugin.cpp"
"network_info_plus_plugin.cpp"
)
apply_standard_settings(${PLUGIN_NAME})
set_target_properties(${PLUGIN_NAME} PROPERTIES
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "include/network_info_plus_windows/network_info.h"
#include "include/network_info_plus/network_info.h"

#include <iphlpapi.h>
#include <iptypes.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// clang-format off
#include "include/network_info_plus_windows/network_info.h"
#include "include/network_info_plus/network_info.h"
// clang-format on
#include "include/network_info_plus_windows/network_info_plus_windows_plugin.h"
#include "include/network_info_plus/network_info_plus_windows_plugin.h"

#include <flutter/method_channel.h>
#include <flutter/plugin_registrar_windows.h>
Expand Down
47 changes: 0 additions & 47 deletions packages/network_info_plus/network_info_plus_linux/.gitignore

This file was deleted.

10 changes: 0 additions & 10 deletions packages/network_info_plus/network_info_plus_linux/.metadata

This file was deleted.

32 changes: 0 additions & 32 deletions packages/network_info_plus/network_info_plus_linux/CHANGELOG.md

This file was deleted.

27 changes: 0 additions & 27 deletions packages/network_info_plus/network_info_plus_linux/LICENSE

This file was deleted.

Loading