From 0abd098ebb5348b4ad0babc438c7e9aba784c4ab Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Wed, 28 Apr 2021 15:19:51 -0700 Subject: [PATCH 1/5] Add implement and registerWith method to plugins --- .../path_provider/lib/path_provider.dart | 5 ++-- .../path_provider_linux/CHANGELOG.md | 5 ++++ .../lib/path_provider_linux.dart | 2 +- .../path_provider_linux/pubspec.yaml | 3 ++- .../test/path_provider_linux_test.dart | 8 +++--- .../path_provider_macos/CHANGELOG.md | 4 +++ .../path_provider_macos/pubspec.yaml | 3 ++- .../path_provider_windows/CHANGELOG.md | 5 ++++ .../lib/src/path_provider_windows_real.dart | 5 ++++ .../lib/src/path_provider_windows_stub.dart | 5 ++++ .../path_provider_windows/pubspec.yaml | 3 ++- .../test/path_provider_windows_test.dart | 25 ++++++++++++------- .../lib/shared_preferences.dart | 5 ++-- .../shared_preferences_linux/CHANGELOG.md | 5 ++++ .../lib/shared_preferences_linux.dart | 7 ++++++ .../shared_preferences_linux/pubspec.yaml | 3 ++- .../test/shared_preferences_linux_test.dart | 11 +++++--- .../shared_preferences_macos/CHANGELOG.md | 4 +++ .../shared_preferences_macos/pubspec.yaml | 3 ++- .../shared_preferences_windows/CHANGELOG.md | 5 ++++ .../lib/shared_preferences_windows.dart | 8 ++++++ .../shared_preferences_windows/pubspec.yaml | 4 +-- .../test/shared_preferences_windows_test.dart | 9 ++++--- 23 files changed, 104 insertions(+), 33 deletions(-) diff --git a/packages/path_provider/path_provider/lib/path_provider.dart b/packages/path_provider/path_provider/lib/path_provider.dart index 341b09f4a314..e690b7f92960 100644 --- a/packages/path_provider/path_provider/lib/path_provider.dart +++ b/packages/path_provider/path_provider/lib/path_provider.dart @@ -42,9 +42,8 @@ class MissingPlatformDirectoryException implements Exception { } PathProviderPlatform get _platform { - // This is to manually endorse Dart implementations until automatic - // registration of Dart plugins is implemented. For details see - // https://github.com/flutter/flutter/issues/52267. + // TODO(egarciad): Remove once auto registration lands on Flutter stable. + // https://github.com/flutter/flutter/issues/81421. if (_manualDartRegistrationNeeded) { // Only do the initial registration if it hasn't already been overridden // with a non-default instance. diff --git a/packages/path_provider/path_provider_linux/CHANGELOG.md b/packages/path_provider/path_provider_linux/CHANGELOG.md index a85c6bbb4ef3..9383181d6a76 100644 --- a/packages/path_provider/path_provider_linux/CHANGELOG.md +++ b/packages/path_provider/path_provider_linux/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.1 + +* Add `implements` to pubspec.yaml. +* Add `registerWith` method to the main Dart class. + ## 2.0.0 * Migrate to null safety. diff --git a/packages/path_provider/path_provider_linux/lib/path_provider_linux.dart b/packages/path_provider/path_provider_linux/lib/path_provider_linux.dart index 5a81114cc92d..38800bee1f2e 100644 --- a/packages/path_provider/path_provider_linux/lib/path_provider_linux.dart +++ b/packages/path_provider/path_provider_linux/lib/path_provider_linux.dart @@ -13,7 +13,7 @@ import 'package:xdg_directories/xdg_directories.dart' as xdg; /// This class implements the `package:path_provider` functionality for linux class PathProviderLinux extends PathProviderPlatform { /// Registers this class as the default instance of [PathProviderPlatform] - static void register() { + static void registerWith() { PathProviderPlatform.instance = PathProviderLinux(); } diff --git a/packages/path_provider/path_provider_linux/pubspec.yaml b/packages/path_provider/path_provider_linux/pubspec.yaml index 5d1c395aa418..b5bea8754dbe 100644 --- a/packages/path_provider/path_provider_linux/pubspec.yaml +++ b/packages/path_provider/path_provider_linux/pubspec.yaml @@ -1,10 +1,11 @@ name: path_provider_linux description: linux implementation of the path_provider plugin -version: 2.0.0 +version: 2.0.1 homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider_linux flutter: plugin: + implements: path_provider platforms: linux: dartPluginClass: PathProviderLinux diff --git a/packages/path_provider/path_provider_linux/test/path_provider_linux_test.dart b/packages/path_provider/path_provider_linux/test/path_provider_linux_test.dart index 3384a3d2f963..e058d0d56039 100644 --- a/packages/path_provider/path_provider_linux/test/path_provider_linux_test.dart +++ b/packages/path_provider/path_provider_linux/test/path_provider_linux_test.dart @@ -7,11 +7,11 @@ import 'package:path_provider_platform_interface/path_provider_platform_interfac void main() { TestWidgetsFlutterBinding.ensureInitialized(); - PathProviderLinux.register(); + PathProviderLinux.registerWith(); - setUp(() {}); - - tearDown(() {}); + test('registered instance', () { + expect(PathProviderPlatform.instance, isA()); + }); test('getTemporaryPath', () async { final PathProviderPlatform plugin = PathProviderPlatform.instance; diff --git a/packages/path_provider/path_provider_macos/CHANGELOG.md b/packages/path_provider/path_provider_macos/CHANGELOG.md index f989efbe2a98..772ebcce8b8f 100644 --- a/packages/path_provider/path_provider_macos/CHANGELOG.md +++ b/packages/path_provider/path_provider_macos/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.1 + +* Add `implements` to pubspec.yaml. + ## 2.0.0 * Update Dart SDK constraint for null safety compatibility. diff --git a/packages/path_provider/path_provider_macos/pubspec.yaml b/packages/path_provider/path_provider_macos/pubspec.yaml index 522ef0a369af..3ebe43e62d9c 100644 --- a/packages/path_provider/path_provider_macos/pubspec.yaml +++ b/packages/path_provider/path_provider_macos/pubspec.yaml @@ -1,10 +1,11 @@ name: path_provider_macos description: macOS implementation of the path_provider plugin -version: 2.0.0 +version: 2.0.1 homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider_macos flutter: plugin: + implements: path_provider platforms: macos: pluginClass: PathProviderPlugin diff --git a/packages/path_provider/path_provider_windows/CHANGELOG.md b/packages/path_provider/path_provider_windows/CHANGELOG.md index 02c3b2300fc0..2e4da0e1f353 100644 --- a/packages/path_provider/path_provider_windows/CHANGELOG.md +++ b/packages/path_provider/path_provider_windows/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.2 + +* Add `implements` to pubspec.yaml. +* Add `registerWith()` to the Dart main class. + ## 2.0.1 * Fix a crash when a known folder can't be located. diff --git a/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart b/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart index 971967373438..2b87d51c1c49 100644 --- a/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart +++ b/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_real.dart @@ -47,6 +47,11 @@ class VersionInfoQuerier { /// /// This class implements the `package:path_provider` functionality for Windows. class PathProviderWindows extends PathProviderPlatform { + /// Registers the Windows implementation. + static void registerWith() { + PathProviderPlatform.instance = PathProviderWindows(); + } + /// The object to use for performing VerQueryValue calls. @visibleForTesting VersionInfoQuerier versionInfoQuerier = VersionInfoQuerier(); diff --git a/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_stub.dart b/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_stub.dart index 91334d95ae24..bc851831bf54 100644 --- a/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_stub.dart +++ b/packages/path_provider/path_provider_windows/lib/src/path_provider_windows_stub.dart @@ -16,6 +16,11 @@ class PathProviderWindows extends PathProviderPlatform { /// compile-time dependencies, and should never actually be created. PathProviderWindows() : assert(false); + /// Registers the Windows implementation. + static void registerWith() { + PathProviderPlatform.instance = PathProviderWindows(); + } + /// Stub; see comment on VersionInfoQuerier. VersionInfoQuerier versionInfoQuerier = VersionInfoQuerier(); diff --git a/packages/path_provider/path_provider_windows/pubspec.yaml b/packages/path_provider/path_provider_windows/pubspec.yaml index d0badefc8d7e..067fec4ceb78 100644 --- a/packages/path_provider/path_provider_windows/pubspec.yaml +++ b/packages/path_provider/path_provider_windows/pubspec.yaml @@ -1,10 +1,11 @@ name: path_provider_windows description: Windows implementation of the path_provider plugin homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider_windows -version: 2.0.1 +version: 2.0.2 flutter: plugin: + implements: path_provider platforms: windows: dartPluginClass: PathProviderWindows diff --git a/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart b/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart index a66c9e1ffb0d..2b22207da355 100644 --- a/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart +++ b/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart @@ -5,6 +5,7 @@ import 'dart:ffi'; import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; +import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; import 'package:path_provider_windows/path_provider_windows.dart'; // A fake VersionInfoQuerier that just returns preset responses. @@ -18,13 +19,19 @@ class FakeVersionInfoQuerier implements VersionInfoQuerier { } void main() { + PathProviderWindows.registerWith(); + + test('registered instance', () { + expect(PathProviderPlatform.instance, isA()); + }); + test('getTemporaryPath', () async { - final PathProviderWindows pathProvider = PathProviderWindows(); + final PathProviderPlatform pathProvider = PathProviderPlatform.instance; expect(await pathProvider.getTemporaryPath(), contains(r'C:\')); }, skip: !Platform.isWindows); test('getApplicationSupportPath with no version info', () async { - final PathProviderWindows pathProvider = PathProviderWindows(); + final PathProviderPlatform pathProvider = PathProviderPlatform.instance; pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({}); final String? path = await pathProvider.getApplicationSupportPath(); @@ -35,7 +42,7 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationSupportPath with full version info', () async { - final PathProviderWindows pathProvider = PathProviderWindows(); + final PathProviderPlatform pathProvider = PathProviderPlatform.instance; pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({ 'CompanyName': 'A Company', 'ProductName': 'Amazing App', @@ -49,7 +56,7 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationSupportPath with missing company', () async { - final PathProviderWindows pathProvider = PathProviderWindows(); + final PathProviderPlatform pathProvider = PathProviderPlatform.instance; pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({ 'ProductName': 'Amazing App', }); @@ -62,7 +69,7 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationSupportPath with problematic values', () async { - final PathProviderWindows pathProvider = PathProviderWindows(); + final PathProviderPlatform pathProvider = PathProviderPlatform.instance; pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({ 'CompanyName': r'A Company: Name.', 'ProductName': r'A"/Terrible\|App?*Name', @@ -80,7 +87,7 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationSupportPath with a completely invalid company', () async { - final PathProviderWindows pathProvider = PathProviderWindows(); + final PathProviderPlatform pathProvider = PathProviderPlatform.instance; pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({ 'CompanyName': r'..', 'ProductName': r'Amazing App', @@ -94,7 +101,7 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationSupportPath with very long app name', () async { - final PathProviderWindows pathProvider = PathProviderWindows(); + final PathProviderPlatform pathProvider = PathProviderPlatform.instance; final String truncatedName = 'A' * 255; pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({ 'CompanyName': 'A Company', @@ -107,14 +114,14 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationDocumentsPath', () async { - final PathProviderWindows pathProvider = PathProviderWindows(); + final PathProviderPlatform pathProvider = PathProviderPlatform.instance; final String? path = await pathProvider.getApplicationDocumentsPath(); expect(path, contains(r'C:\')); expect(path, contains(r'Documents')); }, skip: !Platform.isWindows); test('getDownloadsPath', () async { - final PathProviderWindows pathProvider = PathProviderWindows(); + final PathProviderPlatform pathProvider = PathProviderPlatform.instance; final String? path = await pathProvider.getDownloadsPath(); expect(path, contains(r'C:\')); expect(path, contains(r'Downloads')); diff --git a/packages/shared_preferences/shared_preferences/lib/shared_preferences.dart b/packages/shared_preferences/shared_preferences/lib/shared_preferences.dart index 493e38901ddf..3d2dd051f61c 100644 --- a/packages/shared_preferences/shared_preferences/lib/shared_preferences.dart +++ b/packages/shared_preferences/shared_preferences/lib/shared_preferences.dart @@ -24,9 +24,8 @@ class SharedPreferences { static bool _manualDartRegistrationNeeded = true; static SharedPreferencesStorePlatform get _store { - // This is to manually endorse the Linux implementation until automatic - // registration of dart plugins is implemented. For details see - // https://github.com/flutter/flutter/issues/52267. + // TODO(egarciad): Remove once auto registration lands on Flutter stable. + // https://github.com/flutter/flutter/issues/81421. if (_manualDartRegistrationNeeded) { // Only do the initial registration if it hasn't already been overridden // with a non-default instance. diff --git a/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md b/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md index a50b4e470c53..9a17d2455ad8 100644 --- a/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md +++ b/packages/shared_preferences/shared_preferences_linux/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.1 + +* Add `implements` to the pubspec. +* Add `registerWith` to the Dart main class. + ## 2.0.0 * Migrate to null-safety. diff --git a/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart b/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart index e4fc24e78cff..5ec988216074 100644 --- a/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart +++ b/packages/shared_preferences/shared_preferences_linux/lib/shared_preferences_linux.dart @@ -17,8 +17,15 @@ import 'package:shared_preferences_platform_interface/shared_preferences_platfor /// This class implements the `package:shared_preferences` functionality for Linux. class SharedPreferencesLinux extends SharedPreferencesStorePlatform { /// The default instance of [SharedPreferencesLinux] to use. + /// TODO(egarciad): Remove when the Dart plugin registrant lands on Flutter stable. + /// https://github.com/flutter/flutter/issues/81421 static SharedPreferencesLinux instance = SharedPreferencesLinux(); + /// Registers the Linux implementation. + static void registerWith() { + SharedPreferencesStorePlatform.instance = instance; + } + /// Local copy of preferences Map? _cachedPreferences; diff --git a/packages/shared_preferences/shared_preferences_linux/pubspec.yaml b/packages/shared_preferences/shared_preferences_linux/pubspec.yaml index a573b7cff438..d3bbc1e22363 100644 --- a/packages/shared_preferences/shared_preferences_linux/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_linux/pubspec.yaml @@ -1,10 +1,11 @@ name: shared_preferences_linux description: Linux implementation of the shared_preferences plugin -version: 2.0.0 +version: 2.0.1 homepage: https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences_linux flutter: plugin: + implements: shared_preferences platforms: linux: dartPluginClass: SharedPreferencesLinux diff --git a/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart b/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart index 11e52dd6037f..eb5c49f229f5 100644 --- a/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart +++ b/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart @@ -6,18 +6,19 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:path/path.dart' as path; import 'package:path_provider_linux/path_provider_linux.dart'; import 'package:shared_preferences_linux/shared_preferences_linux.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_platform_interface.dart'; void main() { late MemoryFileSystem fs; + SharedPreferencesLinux.registerWith(); + setUp(() { fs = MemoryFileSystem.test(); }); - tearDown(() {}); - Future _getFilePath() async { - final pathProvider = PathProviderLinux(); + final pathProvider = SharedPreferencesStorePlatform.instance; final directory = await pathProvider.getApplicationSupportPath(); return path.join(directory!, 'shared_preferences.json'); } @@ -38,6 +39,10 @@ void main() { return prefs; } + test('registered instance', () { + expect(SharedPreferencesStorePlatform.instance, isA()); + }); + test('getAll', () async { await _writeTestFile('{"key1": "one", "key2": 2}'); var prefs = _getPreferences(); diff --git a/packages/shared_preferences/shared_preferences_macos/CHANGELOG.md b/packages/shared_preferences/shared_preferences_macos/CHANGELOG.md index 00c2f628796f..ac8dd2c4752b 100644 --- a/packages/shared_preferences/shared_preferences_macos/CHANGELOG.md +++ b/packages/shared_preferences/shared_preferences_macos/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.1 + +* Add `implements` to the pubspec. + ## 2.0.0 * Migrate to null safety. diff --git a/packages/shared_preferences/shared_preferences_macos/pubspec.yaml b/packages/shared_preferences/shared_preferences_macos/pubspec.yaml index b1c883352452..6a5c8c006dbd 100644 --- a/packages/shared_preferences/shared_preferences_macos/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_macos/pubspec.yaml @@ -1,10 +1,11 @@ name: shared_preferences_macos description: macOS implementation of the shared_preferences plugin. -version: 2.0.0 +version: 2.0.1 homepage: https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences_macos flutter: plugin: + implements: shared_preferences platforms: macos: pluginClass: SharedPreferencesPlugin diff --git a/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md b/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md index 6fa4eb162083..34c48f37af48 100644 --- a/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md +++ b/packages/shared_preferences/shared_preferences_windows/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.1 + +* Add `implements` to pubspec.yaml. +* Add `registerWith` to the Dart main class. + ## 2.0.0 * Migrate to null-safety. diff --git a/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart b/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart index 8bbda6ec139a..8118a36cc239 100644 --- a/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart +++ b/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart @@ -15,9 +15,17 @@ import 'package:path_provider_windows/path_provider_windows.dart'; /// /// This class implements the `package:shared_preferences` functionality for Windows. class SharedPreferencesWindows extends SharedPreferencesStorePlatform { + /// The default instance of [SharedPreferencesWindows] to use. + /// TODO(egarciad): Remove when the Dart plugin registrant lands on Flutter stable. + /// https://github.com/flutter/flutter/issues/81421 static SharedPreferencesWindows instance = SharedPreferencesWindows(); + /// Registers the Windows implementation. + static void registerWith() { + SharedPreferencesStorePlatform.instance = instance; + } + /// File system used to store to disk. Exposed for testing only. @visibleForTesting FileSystem fs = LocalFileSystem(); diff --git a/packages/shared_preferences/shared_preferences_windows/pubspec.yaml b/packages/shared_preferences/shared_preferences_windows/pubspec.yaml index cafb6b767045..4e8327cadb33 100644 --- a/packages/shared_preferences/shared_preferences_windows/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_windows/pubspec.yaml @@ -1,11 +1,11 @@ name: shared_preferences_windows description: Windows implementation of shared_preferences homepage: https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences_windows -version: 2.0.0 - +version: 2.0.1 flutter: plugin: + implements: shared_preferences platforms: windows: dartPluginClass: SharedPreferencesWindows diff --git a/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart b/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart index e577b9f76e48..e51c5a36b7f6 100644 --- a/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart +++ b/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart @@ -7,6 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:path/path.dart' as path; import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; import 'package:path_provider_windows/path_provider_windows.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_platform_interface.dart'; import 'package:shared_preferences_windows/shared_preferences_windows.dart'; void main() { @@ -18,8 +19,6 @@ void main() { pathProvider = FakePathProviderWindows(); }); - tearDown(() {}); - Future _getFilePath() async { final directory = await pathProvider.getApplicationSupportPath(); return path.join(directory!, 'shared_preferences.json'); @@ -36,12 +35,16 @@ void main() { } SharedPreferencesWindows _getPreferences() { - var prefs = SharedPreferencesWindows(); + var prefs = SharedPreferencesStorePlatform.instance; prefs.fs = fileSystem; prefs.pathProvider = pathProvider; return prefs; } + test('registered instance', () { + expect(SharedPreferencesStorePlatform.instance, isA()); + }); + test('getAll', () async { await _writeTestFile('{"key1": "one", "key2": 2}'); var prefs = _getPreferences(); From 84dd0a3b937a6eff657fadbe59f75970bb04e0e8 Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Wed, 28 Apr 2021 15:28:32 -0700 Subject: [PATCH 2/5] Format --- .../test/shared_preferences_linux_test.dart | 3 ++- .../lib/shared_preferences_windows.dart | 1 - .../test/shared_preferences_windows_test.dart | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart b/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart index eb5c49f229f5..aef1bf666bbc 100644 --- a/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart +++ b/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart @@ -40,7 +40,8 @@ void main() { } test('registered instance', () { - expect(SharedPreferencesStorePlatform.instance, isA()); + expect( + SharedPreferencesStorePlatform.instance, isA()); }); test('getAll', () async { diff --git a/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart b/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart index 8118a36cc239..b8cd3702b837 100644 --- a/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart +++ b/packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart @@ -15,7 +15,6 @@ import 'package:path_provider_windows/path_provider_windows.dart'; /// /// This class implements the `package:shared_preferences` functionality for Windows. class SharedPreferencesWindows extends SharedPreferencesStorePlatform { - /// The default instance of [SharedPreferencesWindows] to use. /// TODO(egarciad): Remove when the Dart plugin registrant lands on Flutter stable. /// https://github.com/flutter/flutter/issues/81421 diff --git a/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart b/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart index e51c5a36b7f6..5e475549776a 100644 --- a/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart +++ b/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart @@ -42,7 +42,8 @@ void main() { } test('registered instance', () { - expect(SharedPreferencesStorePlatform.instance, isA()); + expect(SharedPreferencesStorePlatform.instance, + isA()); }); test('getAll', () async { From 568b284505280f624d49096b15bb5b9cb8e6731c Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Wed, 28 Apr 2021 15:40:24 -0700 Subject: [PATCH 3/5] Keep platform instance --- .../test/path_provider_windows_test.dart | 21 +++++++++---------- .../test/shared_preferences_linux_test.dart | 2 +- .../test/shared_preferences_windows_test.dart | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart b/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart index 2b22207da355..e977e07d99e6 100644 --- a/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart +++ b/packages/path_provider/path_provider_windows/test/path_provider_windows_test.dart @@ -19,19 +19,18 @@ class FakeVersionInfoQuerier implements VersionInfoQuerier { } void main() { - PathProviderWindows.registerWith(); - test('registered instance', () { + PathProviderWindows.registerWith(); expect(PathProviderPlatform.instance, isA()); }); test('getTemporaryPath', () async { - final PathProviderPlatform pathProvider = PathProviderPlatform.instance; + final PathProviderWindows pathProvider = PathProviderWindows(); expect(await pathProvider.getTemporaryPath(), contains(r'C:\')); }, skip: !Platform.isWindows); test('getApplicationSupportPath with no version info', () async { - final PathProviderPlatform pathProvider = PathProviderPlatform.instance; + final PathProviderWindows pathProvider = PathProviderWindows(); pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({}); final String? path = await pathProvider.getApplicationSupportPath(); @@ -42,7 +41,7 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationSupportPath with full version info', () async { - final PathProviderPlatform pathProvider = PathProviderPlatform.instance; + final PathProviderWindows pathProvider = PathProviderWindows(); pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({ 'CompanyName': 'A Company', 'ProductName': 'Amazing App', @@ -56,7 +55,7 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationSupportPath with missing company', () async { - final PathProviderPlatform pathProvider = PathProviderPlatform.instance; + final PathProviderWindows pathProvider = PathProviderWindows(); pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({ 'ProductName': 'Amazing App', }); @@ -69,7 +68,7 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationSupportPath with problematic values', () async { - final PathProviderPlatform pathProvider = PathProviderPlatform.instance; + final PathProviderWindows pathProvider = PathProviderWindows(); pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({ 'CompanyName': r'A Company: Name.', 'ProductName': r'A"/Terrible\|App?*Name', @@ -87,7 +86,7 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationSupportPath with a completely invalid company', () async { - final PathProviderPlatform pathProvider = PathProviderPlatform.instance; + final PathProviderWindows pathProvider = PathProviderWindows(); pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({ 'CompanyName': r'..', 'ProductName': r'Amazing App', @@ -101,7 +100,7 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationSupportPath with very long app name', () async { - final PathProviderPlatform pathProvider = PathProviderPlatform.instance; + final PathProviderWindows pathProvider = PathProviderWindows(); final String truncatedName = 'A' * 255; pathProvider.versionInfoQuerier = FakeVersionInfoQuerier({ 'CompanyName': 'A Company', @@ -114,14 +113,14 @@ void main() { }, skip: !Platform.isWindows); test('getApplicationDocumentsPath', () async { - final PathProviderPlatform pathProvider = PathProviderPlatform.instance; + final PathProviderWindows pathProvider = PathProviderWindows(); final String? path = await pathProvider.getApplicationDocumentsPath(); expect(path, contains(r'C:\')); expect(path, contains(r'Documents')); }, skip: !Platform.isWindows); test('getDownloadsPath', () async { - final PathProviderPlatform pathProvider = PathProviderPlatform.instance; + final PathProviderWindows pathProvider = PathProviderWindows(); final String? path = await pathProvider.getDownloadsPath(); expect(path, contains(r'C:\')); expect(path, contains(r'Downloads')); diff --git a/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart b/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart index aef1bf666bbc..62ec2b66c07a 100644 --- a/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart +++ b/packages/shared_preferences/shared_preferences_linux/test/shared_preferences_linux_test.dart @@ -18,7 +18,7 @@ void main() { }); Future _getFilePath() async { - final pathProvider = SharedPreferencesStorePlatform.instance; + final pathProvider = PathProviderLinux(); final directory = await pathProvider.getApplicationSupportPath(); return path.join(directory!, 'shared_preferences.json'); } diff --git a/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart b/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart index 5e475549776a..2717cbead866 100644 --- a/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart +++ b/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart @@ -35,7 +35,7 @@ void main() { } SharedPreferencesWindows _getPreferences() { - var prefs = SharedPreferencesStorePlatform.instance; + var prefs = SharedPreferencesWindows.instance; prefs.fs = fileSystem; prefs.pathProvider = pathProvider; return prefs; From 283816eaf57fbb25e601a7be155089798923c1ec Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Wed, 28 Apr 2021 15:51:15 -0700 Subject: [PATCH 4/5] Fix test --- .../test/shared_preferences_windows_test.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart b/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart index 2717cbead866..6bb21b814e07 100644 --- a/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart +++ b/packages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart @@ -35,13 +35,14 @@ void main() { } SharedPreferencesWindows _getPreferences() { - var prefs = SharedPreferencesWindows.instance; + var prefs = SharedPreferencesWindows(); prefs.fs = fileSystem; prefs.pathProvider = pathProvider; return prefs; } test('registered instance', () { + SharedPreferencesWindows.registerWith(); expect(SharedPreferencesStorePlatform.instance, isA()); }); From 6f448b96fe030f2ee2472c7655d37984bec7fbbc Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Thu, 29 Apr 2021 10:00:46 -0700 Subject: [PATCH 5/5] [connectivity_macos] Add dependency on platform interface --- packages/connectivity/connectivity_macos/CHANGELOG.md | 4 ++++ packages/connectivity/connectivity_macos/pubspec.yaml | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/connectivity/connectivity_macos/CHANGELOG.md b/packages/connectivity/connectivity_macos/CHANGELOG.md index 7031e48318dd..0d962362a99f 100644 --- a/packages/connectivity/connectivity_macos/CHANGELOG.md +++ b/packages/connectivity/connectivity_macos/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.1 + +* Add `implements` to pubspec.yaml. + ## 0.2.0 * Remove placeholder Dart file. diff --git a/packages/connectivity/connectivity_macos/pubspec.yaml b/packages/connectivity/connectivity_macos/pubspec.yaml index b78db9baa0d2..66e853c89e75 100644 --- a/packages/connectivity/connectivity_macos/pubspec.yaml +++ b/packages/connectivity/connectivity_macos/pubspec.yaml @@ -1,10 +1,11 @@ name: connectivity_macos description: macOS implementation of the connectivity plugin. -version: 0.2.0 +version: 0.2.1 homepage: https://github.com/flutter/plugins/tree/master/packages/connectivity/connectivity_macos flutter: plugin: + implements: connectivity_platform_interface platforms: macos: pluginClass: ConnectivityPlugin @@ -16,6 +17,13 @@ environment: dependencies: flutter: sdk: flutter + # The implementation of this plugin doesn't explicitly depend on the method channel + # defined in the platform interface. + # To prevent potential breakages, this dependency is added. + # + # In the future, this plugin's platform code should be able to reference the + # interface's platform code. (Android already supports this). + connectivity_platform_interface: ^2.0.0 dev_dependencies: pedantic: ^1.10.0