[connectivity] Endorse macos implementation (#2538)
* Add files and name
* Passed all methods
* Works for Android
* Small cleanup
* Starting tests
* [connectivity] Move as much logic as possible to the MethodChannel implementation.
connectivity_platform_interface:
* Bring ConnectivityResult and LocationAuthorizationStatus enums from
core package.
* Use the above Enums as return values for ConnectivityPlatformInterface
methods.
* Modify the MethodChannel implementation so it returns the right types.
* Bring utility methods, asserts and other logic that is only needed on
the MethodChannel implementation from the core package, so it's simpler.
* Bring MethodChannel unit tests from core package.
connectivity (core pkg):
* Reexport ConnectivityResult and LocationAuthorizationStatus enums so
plugin users can see them.
* Remove MethodChannel unit tests (moved to platform_interface).
* Format test
* Move all files
* Fix versions
* Fix version
* Fix path
* Add test
* Add test
* Add no-op macos
* Endorse in pubspec
* Update version and README
* Add macos example
* Add e2e test files
* Update version and changelog
* Remove ephemeral
* Change version
* Update versions
* Remove registrant
* Change to any
Co-authored-by: David Iglesias <ditman@gmail.com>
diff --git a/packages/connectivity/connectivity/CHANGELOG.md b/packages/connectivity/connectivity/CHANGELOG.md
index f1f5fdc..89d11f4 100644
--- a/packages/connectivity/connectivity/CHANGELOG.md
+++ b/packages/connectivity/connectivity/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.4.8
+
+* Adds macOS as an endorsed platform.
+
## 0.4.7
* Migrate the plugin to use the ConnectivityPlatform.instance defined in the connectivity_platform_interface package.
diff --git a/packages/connectivity/connectivity/example/lib/main.dart b/packages/connectivity/connectivity/example/lib/main.dart
index 0d9c282..4ad3097 100644
--- a/packages/connectivity/connectivity/example/lib/main.dart
+++ b/packages/connectivity/connectivity/example/lib/main.dart
@@ -15,7 +15,7 @@
// Sets a platform override for desktop to avoid exceptions. See
// https://flutter.dev/desktop#target-platform-override for more info.
void _enablePlatformOverrideForDesktop() {
- if (!kIsWeb && (Platform.isMacOS || Platform.isWindows || Platform.isLinux)) {
+ if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
}
}
diff --git a/packages/connectivity/connectivity/example/pubspec.yaml b/packages/connectivity/connectivity/example/pubspec.yaml
index c0914e4..2f2b6eb 100644
--- a/packages/connectivity/connectivity/example/pubspec.yaml
+++ b/packages/connectivity/connectivity/example/pubspec.yaml
@@ -6,8 +6,6 @@
sdk: flutter
connectivity:
path: ../
- connectivity_macos:
- path: ../../connectivity_macos
dev_dependencies:
flutter_driver:
diff --git a/packages/connectivity/connectivity/example/test_driver/test/connectivity_e2e.dart b/packages/connectivity/connectivity/example/test_driver/test/connectivity_e2e.dart
new file mode 100644
index 0000000..10c4bda
--- /dev/null
+++ b/packages/connectivity/connectivity/example/test_driver/test/connectivity_e2e.dart
@@ -0,0 +1,41 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'dart:io';
+import 'package:e2e/e2e.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:connectivity/connectivity.dart';
+
+void main() {
+ E2EWidgetsFlutterBinding.ensureInitialized();
+
+ group('Connectivity test driver', () {
+ Connectivity _connectivity;
+
+ setUpAll(() async {
+ _connectivity = Connectivity();
+ });
+
+ testWidgets('test connectivity result', (WidgetTester tester) async {
+ final ConnectivityResult result = await _connectivity.checkConnectivity();
+ expect(result, isNotNull);
+ switch (result) {
+ case ConnectivityResult.wifi:
+ expect(_connectivity.getWifiName(), completes);
+ expect(_connectivity.getWifiBSSID(), completes);
+ expect((await _connectivity.getWifiIP()), isNotNull);
+ break;
+ default:
+ break;
+ }
+ });
+
+ testWidgets('test location methods, iOS only', (WidgetTester tester) async {
+ if (Platform.isIOS) {
+ expect((await _connectivity.getLocationServiceAuthorization()),
+ LocationAuthorizationStatus.notDetermined);
+ }
+ });
+ });
+}
diff --git a/packages/connectivity/connectivity/macos/connectivity.podspec b/packages/connectivity/connectivity/macos/connectivity.podspec
new file mode 100644
index 0000000..ea544df
--- /dev/null
+++ b/packages/connectivity/connectivity/macos/connectivity.podspec
@@ -0,0 +1,22 @@
+#
+# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
+#
+Pod::Spec.new do |s|
+ s.name = 'connectivity'
+ s.version = '0.0.1'
+ s.summary = 'No-op implementation of the macos connectivity to avoid build issues on macos'
+ s.description = <<-DESC
+ No-op implementation of the connectivity plugin to avoid build issues on macos.
+ https://github.com/flutter/flutter/issues/46618
+ DESC
+ s.homepage = 'https://github.com/flutter/plugins/tree/master/packages/connectivity'
+ s.license = { :file => '../LICENSE' }
+ s.author = { 'Flutter Team' => 'flutter-dev@googlegroups.com' }
+ s.source = { :path => '.' }
+ s.source_files = 'Classes/**/*'
+ s.public_header_files = 'Classes/**/*.h'
+
+ s.platform = :osx
+ s.osx.deployment_target = '10.11'
+end
+
diff --git a/packages/connectivity/connectivity/pubspec.yaml b/packages/connectivity/connectivity/pubspec.yaml
index de0f5de..7542e80 100644
--- a/packages/connectivity/connectivity/pubspec.yaml
+++ b/packages/connectivity/connectivity/pubspec.yaml
@@ -2,7 +2,7 @@
description: Flutter plugin for discovering the state of the network (WiFi &
mobile/cellular) connectivity on Android and iOS.
homepage: https://github.com/flutter/plugins/tree/master/packages/connectivity/connectivity
-version: 0.4.7
+version: 0.4.8
flutter:
plugin:
@@ -12,12 +12,15 @@
pluginClass: ConnectivityPlugin
ios:
pluginClass: FLTConnectivityPlugin
+ macos:
+ default_package: connectivity_macos
dependencies:
flutter:
sdk: flutter
meta: "^1.0.5"
connectivity_platform_interface: ^1.0.2
+ connectivity_macos: ^0.1.0
dev_dependencies:
flutter_test: