[path_provider] now supports getDownloadsDirectory() on macOS. (#2436)

Adds support for retrieving a user's downloads directory on macOS using the path_provider plugin.
diff --git a/packages/path_provider/CHANGELOG.md b/packages/path_provider/CHANGELOG.md
index ee7163f..ad26ead 100644
--- a/packages/path_provider/CHANGELOG.md
+++ b/packages/path_provider/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 1.6.0
+
+* Support for retrieving the downloads directory was added.
+  The call for this is `getDownloadsDirectory`.
+
 ## 1.5.1
 
 * Remove the deprecated `author:` field from pubspec.yaml
diff --git a/packages/path_provider/lib/path_provider.dart b/packages/path_provider/lib/path_provider.dart
index 52aceb7..b27cc4b 100644
--- a/packages/path_provider/lib/path_provider.dart
+++ b/packages/path_provider/lib/path_provider.dart
@@ -216,3 +216,23 @@
 
   return paths.map((String path) => Directory(path)).toList();
 }
+
+/// Path to the directory where downloaded files can be stored.
+/// This is typically only relevant on desktop operating systems.
+///
+/// On Android and on iOS, this function throws an [UnsupportedError] as no equivalent
+/// path exists.
+Future<Directory> getDownloadsDirectory() async {
+  if (_platform.isAndroid) {
+    throw UnsupportedError('Functionality not available on Android');
+  }
+  if (_platform.isIOS) {
+    throw UnsupportedError('Functionality not available on iOS');
+  }
+  final String path =
+      await _channel.invokeMethod<String>('getDownloadsDirectory');
+  if (path == null) {
+    return null;
+  }
+  return Directory(path);
+}
diff --git a/packages/path_provider/path_provider_macos/CHANGELOG.md b/packages/path_provider/path_provider_macos/CHANGELOG.md
index 3e3607e..ae674a2 100644
--- a/packages/path_provider/path_provider_macos/CHANGELOG.md
+++ b/packages/path_provider/path_provider_macos/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.0.3
+
+* Added support for user's downloads directory.
+
 ## 0.0.2+1
 
 * Update README.
diff --git a/packages/path_provider/path_provider_macos/macos/Classes/PathProviderPlugin.swift b/packages/path_provider/path_provider_macos/macos/Classes/PathProviderPlugin.swift
index 4ceb006..cb56fc4 100644
--- a/packages/path_provider/path_provider_macos/macos/Classes/PathProviderPlugin.swift
+++ b/packages/path_provider/path_provider_macos/macos/Classes/PathProviderPlugin.swift
@@ -49,6 +49,8 @@
       result(path)
     case "getLibraryDirectory":
       result(getDirectory(ofType: FileManager.SearchPathDirectory.libraryDirectory))
+    case "getDownloadsDirectory":
+      result(getDirectory(ofType: FileManager.SearchPathDirectory.downloadsDirectory))
     default:
       result(FlutterMethodNotImplemented)
     }
diff --git a/packages/path_provider/path_provider_macos/pubspec.yaml b/packages/path_provider/path_provider_macos/pubspec.yaml
index 82acee9..ca04d59 100644
--- a/packages/path_provider/path_provider_macos/pubspec.yaml
+++ b/packages/path_provider/path_provider_macos/pubspec.yaml
@@ -1,6 +1,6 @@
 name: path_provider_macos
 description: macOS implementation of the path_provider plugin
-version: 0.0.2+1
+version: 0.0.3
 homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider_macos
 
 flutter:
diff --git a/packages/path_provider/pubspec.yaml b/packages/path_provider/pubspec.yaml
index 730e7a5..e884c0f 100644
--- a/packages/path_provider/pubspec.yaml
+++ b/packages/path_provider/pubspec.yaml
@@ -2,7 +2,7 @@
 description: Flutter plugin for getting commonly used locations on the Android &
   iOS file systems, such as the temp and app data directories.
 homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider
-version: 1.5.1
+version: 1.6.0
 
 flutter:
   plugin:
diff --git a/packages/path_provider/test/path_provider_test.dart b/packages/path_provider/test/path_provider_test.dart
index 7af3788..5b875e3 100644
--- a/packages/path_provider/test/path_provider_test.dart
+++ b/packages/path_provider/test/path_provider_test.dart
@@ -226,4 +226,12 @@
     );
     expect(directories.map((Directory d) => d.path).toList(), equals(paths));
   });
+
+  test('DownloadsDirectory path macos test', () async {
+    setMockPathProviderPlatform(FakePlatform(operatingSystem: 'macos'));
+    final String fakePath = "/foo/bar/baz";
+    response = fakePath;
+    final Directory directory = await getDownloadsDirectory();
+    expect(directory.path, equals(fakePath));
+  });
 }