[path_provider] Fix Unchecked/Unsafe Operation Warning (#5267)
diff --git a/packages/path_provider/path_provider_android/CHANGELOG.md b/packages/path_provider/path_provider_android/CHANGELOG.md
index 7b04e90..31f8c81 100644
--- a/packages/path_provider/path_provider_android/CHANGELOG.md
+++ b/packages/path_provider/path_provider_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.0.13
+
+* Fixes typing build warning.
+
## 2.0.12
* Returns to using a different platform channel name, undoing the revert in
diff --git a/packages/path_provider/path_provider_android/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java b/packages/path_provider/path_provider_android/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java
index 278ff58..6dcf959 100644
--- a/packages/path_provider/path_provider_android/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java
+++ b/packages/path_provider/path_provider_android/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java
@@ -17,16 +17,14 @@
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
+import io.flutter.plugin.common.BinaryMessenger.TaskQueue;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
-import io.flutter.plugin.common.MethodCodec;
import io.flutter.plugin.common.StandardMethodCodec;
import io.flutter.util.PathUtils;
import java.io.File;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
@@ -154,25 +152,17 @@
private void setup(BinaryMessenger messenger, Context context) {
String channelName = "plugins.flutter.io/path_provider_android";
- // TODO(gaaclarke): Remove reflection guard when https://github.com/flutter/engine/pull/29147
- // becomes available on the stable branch.
+ TaskQueue taskQueue = messenger.makeBackgroundTaskQueue();
+
try {
- Class methodChannelClass = Class.forName("io.flutter.plugin.common.MethodChannel");
- Class taskQueueClass = Class.forName("io.flutter.plugin.common.BinaryMessenger$TaskQueue");
- Method makeBackgroundTaskQueue = messenger.getClass().getMethod("makeBackgroundTaskQueue");
- Object taskQueue = makeBackgroundTaskQueue.invoke(messenger);
- Constructor<MethodChannel> constructor =
- methodChannelClass.getConstructor(
- BinaryMessenger.class, String.class, MethodCodec.class, taskQueueClass);
channel =
- constructor.newInstance(messenger, channelName, StandardMethodCodec.INSTANCE, taskQueue);
+ (MethodChannel)
+ new MethodChannel(messenger, channelName, StandardMethodCodec.INSTANCE, taskQueue);
impl = new PathProviderBackgroundThread();
- Log.d(TAG, "Use TaskQueues.");
} catch (Exception ex) {
- channel = new MethodChannel(messenger, channelName);
- impl = new PathProviderPlatformThread();
- Log.d(TAG, "Don't use TaskQueues.");
+ Log.e(TAG, "Received exception while setting up PathProviderPlugin", ex);
}
+
this.context = context;
channel.setMethodCallHandler(this);
}
diff --git a/packages/path_provider/path_provider_android/pubspec.yaml b/packages/path_provider/path_provider_android/pubspec.yaml
index 63b9330..93ed984 100644
--- a/packages/path_provider/path_provider_android/pubspec.yaml
+++ b/packages/path_provider/path_provider_android/pubspec.yaml
@@ -2,11 +2,11 @@
description: Android implementation of the path_provider plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/path_provider/path_provider_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+path_provider%22
-version: 2.0.12
+version: 2.0.13
environment:
sdk: ">=2.14.0 <3.0.0"
- flutter: ">=2.8.0"
+ flutter: ">=2.8.1"
flutter:
plugin: