[path_provider_platform_interface] Add getApplicationCachePath() (#4614)

Platform interface changes split out from #4483.

/cc @stuartmorgan
diff --git a/packages/path_provider/path_provider_platform_interface/CHANGELOG.md b/packages/path_provider/path_provider_platform_interface/CHANGELOG.md
index f96711b..051c0e5 100644
--- a/packages/path_provider/path_provider_platform_interface/CHANGELOG.md
+++ b/packages/path_provider/path_provider_platform_interface/CHANGELOG.md
@@ -1,5 +1,6 @@
-## NEXT
+## 2.1.0
 
+* Adds getApplicationCachePath() for storing app-specific cache files.
 * Updates minimum supported SDK version to Flutter 3.3/Dart 2.18.
 * Aligns Dart and Flutter SDK constraints.
 
diff --git a/packages/path_provider/path_provider_platform_interface/lib/path_provider_platform_interface.dart b/packages/path_provider/path_provider_platform_interface/lib/path_provider_platform_interface.dart
index 517ac74..682d1ef 100644
--- a/packages/path_provider/path_provider_platform_interface/lib/path_provider_platform_interface.dart
+++ b/packages/path_provider/path_provider_platform_interface/lib/path_provider_platform_interface.dart
@@ -62,6 +62,12 @@
         'getApplicationDocumentsPath() has not been implemented.');
   }
 
+  /// Path to a directory where application specific cache data can be stored.
+  Future<String?> getApplicationCachePath() {
+    throw UnimplementedError(
+        'getApplicationCachePath() has not been implemented.');
+  }
+
   /// Path to a directory where the application may access top level storage.
   /// The current operating system should be determined before issuing this
   /// function call, as this functionality is only available on Android.
diff --git a/packages/path_provider/path_provider_platform_interface/lib/src/method_channel_path_provider.dart b/packages/path_provider/path_provider_platform_interface/lib/src/method_channel_path_provider.dart
index 991be55..02729f8 100644
--- a/packages/path_provider/path_provider_platform_interface/lib/src/method_channel_path_provider.dart
+++ b/packages/path_provider/path_provider_platform_interface/lib/src/method_channel_path_provider.dart
@@ -53,6 +53,11 @@
   }
 
   @override
+  Future<String?> getApplicationCachePath() {
+    return methodChannel.invokeMethod<String>('getApplicationCacheDirectory');
+  }
+
+  @override
   Future<String?> getExternalStoragePath() {
     if (!_platform.isAndroid) {
       throw UnsupportedError('Functionality only available on Android');
diff --git a/packages/path_provider/path_provider_platform_interface/pubspec.yaml b/packages/path_provider/path_provider_platform_interface/pubspec.yaml
index 193bb85..44eb59a 100644
--- a/packages/path_provider/path_provider_platform_interface/pubspec.yaml
+++ b/packages/path_provider/path_provider_platform_interface/pubspec.yaml
@@ -4,7 +4,7 @@
 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+path_provider%22
 # NOTE: We strongly prefer non-breaking changes, even at the expense of a
 # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
-version: 2.0.6
+version: 2.1.0
 
 environment:
   sdk: ">=2.18.0 <4.0.0"
diff --git a/packages/path_provider/path_provider_platform_interface/test/method_channel_path_provider_test.dart b/packages/path_provider/path_provider_platform_interface/test/method_channel_path_provider_test.dart
index 035e7be..2c68ec5 100644
--- a/packages/path_provider/path_provider_platform_interface/test/method_channel_path_provider_test.dart
+++ b/packages/path_provider/path_provider_platform_interface/test/method_channel_path_provider_test.dart
@@ -14,6 +14,7 @@
   const String kApplicationSupportPath = 'applicationSupportPath';
   const String kLibraryPath = 'libraryPath';
   const String kApplicationDocumentsPath = 'applicationDocumentsPath';
+  const String kApplicationCachePath = 'applicationCachePath';
   const String kExternalCachePaths = 'externalCachePaths';
   const String kExternalStoragePaths = 'externalStoragePaths';
   const String kDownloadsPath = 'downloadsPath';
@@ -39,6 +40,8 @@
             return kLibraryPath;
           case 'getApplicationDocumentsDirectory':
             return kApplicationDocumentsPath;
+          case 'getApplicationCacheDirectory':
+            return kApplicationCachePath;
           case 'getExternalStorageDirectories':
             return <String>[kExternalStoragePaths];
           case 'getExternalCacheDirectories':
@@ -126,6 +129,18 @@
       expect(path, kApplicationDocumentsPath);
     });
 
+    test('getApplicationCachePath succeeds', () async {
+      final String? result =
+          await methodChannelPathProvider.getApplicationCachePath();
+      expect(
+        log,
+        <Matcher>[
+          isMethodCall('getApplicationCacheDirectory', arguments: null)
+        ],
+      );
+      expect(result, kApplicationCachePath);
+    });
+
     test('getExternalCachePaths android succeeds', () async {
       final List<String>? result =
           await methodChannelPathProvider.getExternalCachePaths();
diff --git a/packages/path_provider/path_provider_platform_interface/test/path_provider_platform_interface_test.dart b/packages/path_provider/path_provider_platform_interface/test/path_provider_platform_interface_test.dart
new file mode 100644
index 0000000..9d9bc85
--- /dev/null
+++ b/packages/path_provider/path_provider_platform_interface/test/path_provider_platform_interface_test.dart
@@ -0,0 +1,29 @@
+// Copyright 2013 The Flutter 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 'package:flutter_test/flutter_test.dart';
+import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
+import 'package:path_provider_platform_interface/src/method_channel_path_provider.dart';
+
+void main() {
+  TestWidgetsFlutterBinding.ensureInitialized();
+
+  group('$PathProviderPlatform', () {
+    test('$MethodChannelPathProvider is the default instance', () {
+      expect(PathProviderPlatform.instance, isA<MethodChannelPathProvider>());
+    });
+
+    test('getApplicationCachePath throws unimplemented error', () {
+      final ExtendsPathProviderPlatform pathProviderPlatform =
+          ExtendsPathProviderPlatform();
+
+      expect(
+        () => pathProviderPlatform.getApplicationCachePath(),
+        throwsUnimplementedError,
+      );
+    });
+  });
+}
+
+class ExtendsPathProviderPlatform extends PathProviderPlatform {}