[image_picker] Fix Android lints (#3887)

Removes the lint-baseline.xml and fixes the resulting issues. Also does some Andoid-Studio-suggested auto-conversions of anonymous classes to lambdas.

Part of https://github.com/flutter/flutter/issues/88011
diff --git a/packages/image_picker/image_picker_android/CHANGELOG.md b/packages/image_picker/image_picker_android/CHANGELOG.md
index 654a05f..b0a583f 100644
--- a/packages/image_picker/image_picker_android/CHANGELOG.md
+++ b/packages/image_picker/image_picker_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.8.6+14
+
+* Fixes Java warnings.
+
 ## 0.8.6+13
 
 * Fixes `BuildContext` handling in example.
diff --git a/packages/image_picker/image_picker_android/android/build.gradle b/packages/image_picker/image_picker_android/android/build.gradle
index 08b4bb3..367aa85 100644
--- a/packages/image_picker/image_picker_android/android/build.gradle
+++ b/packages/image_picker/image_picker_android/android/build.gradle
@@ -36,7 +36,6 @@
         checkAllWarnings true
         warningsAsErrors true
         disable 'AndroidGradlePluginVersion', 'InvalidPackage', 'GradleDependency'
-        baseline file("lint-baseline.xml")
     }
     dependencies {
         implementation 'androidx.core:core:1.9.0'
diff --git a/packages/image_picker/image_picker_android/android/lint-baseline.xml b/packages/image_picker/image_picker_android/android/lint-baseline.xml
deleted file mode 100644
index 765a6ca..0000000
--- a/packages/image_picker/image_picker_android/android/lint-baseline.xml
+++ /dev/null
@@ -1,400 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 7.1.2" type="baseline" client="gradle" dependencies="false" name="AGP (7.1.2)" variant="all" version="7.1.2">
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` constructor of class `PendingCallState` requires synthetic accessor"
-        errorLine1="          new PendingCallState(pendingImageOptions, pendingVideoOptions, result);"
-        errorLine2="          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="213"
-            column="11"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` method `handleImageResult` of class `ImagePickerDelegate` requires synthetic accessor"
-        errorLine1="              handleImageResult(path, true);"
-        errorLine2="              ~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="614"
-            column="15"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` method `handleVideoResult` of class `ImagePickerDelegate` requires synthetic accessor"
-        errorLine1="              handleVideoResult(path);"
-        errorLine2="              ~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="633"
-            column="15"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` constructor of class `PendingCallState` requires synthetic accessor"
-        errorLine1="    pendingCallState = new PendingCallState(imageOptions, videoOptions, result);"
-        errorLine2="                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="697"
-            column="24"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` field `activityState` of class `ImagePickerPlugin` requires synthetic accessor"
-        errorLine1="        activityState.getDelegate().saveStateBeforeResult();"
-        errorLine2="        ~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java"
-            line="89"
-            column="9"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` constructor of class `ImageSelectionOptions` requires synthetic accessor"
-        errorLine1="        ImageSelectionOptions pigeonReturn = new ImageSelectionOptions();"
-        errorLine2="                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="164"
-            column="46"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` constructor of class `SourceSpecification` requires synthetic accessor"
-        errorLine1="        SourceSpecification pigeonReturn = new SourceSpecification();"
-        errorLine2="                                           ~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="298"
-            column="44"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` field `index` of class `SourceType` requires synthetic accessor"
-        errorLine1="      toListResult.add(type == null ? null : type.index);"
-        errorLine2="                                                  ~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="308"
-            column="51"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` field `index` of class `SourceCamera` requires synthetic accessor"
-        errorLine1="      toListResult.add(camera == null ? null : camera.index);"
-        errorLine2="                                                      ~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="309"
-            column="55"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` constructor of class `CacheRetrievalError` requires synthetic accessor"
-        errorLine1="        CacheRetrievalError pigeonReturn = new CacheRetrievalError();"
-        errorLine2="                                           ~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="374"
-            column="44"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` constructor of class `CacheRetrievalResult` requires synthetic accessor"
-        errorLine1="        CacheRetrievalResult pigeonReturn = new CacheRetrievalResult();"
-        errorLine2="                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="476"
-            column="45"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` field `index` of class `CacheRetrievalType` requires synthetic accessor"
-        errorLine1="      toListResult.add(type == null ? null : type.index);"
-        errorLine2="                                                  ~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="487"
-            column="51"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` method `wrapError` of class `Messages` requires synthetic accessor"
-        errorLine1="                        ArrayList&lt;Object> wrappedError = wrapError(error);"
-        errorLine2="                                                         ~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="615"
-            column="58"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` method `wrapError` of class `Messages` requires synthetic accessor"
-        errorLine1="                        ArrayList&lt;Object> wrappedError = wrapError(error);"
-        errorLine2="                                                         ~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="648"
-            column="58"/>
-    </issue>
-
-    <issue
-        id="SyntheticAccessor"
-        message="Access to `private` method `wrapError` of class `Messages` requires synthetic accessor"
-        errorLine1="                  ArrayList&lt;Object> wrappedError = wrapError(exception);"
-        errorLine2="                                                   ~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="674"
-            column="52"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      final Activity activity,"
-        errorLine2="            ~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="139"
-            column="13"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      final File externalFilesDirectory,"
-        errorLine2="            ~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="140"
-            column="13"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      final ImageResizer imageResizer,"
-        errorLine2="            ~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="141"
-            column="13"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      final ImagePickerCache cache) {"
-        errorLine2="            ~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="142"
-            column="13"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      VideoSelectionOptions options, boolean usePhotoPicker, Messages.Result&lt;List&lt;String>> result) {"
-        errorLine2="      ~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="280"
-            column="7"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      VideoSelectionOptions options, boolean usePhotoPicker, Messages.Result&lt;List&lt;String>> result) {"
-        errorLine2="                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="280"
-            column="62"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      VideoSelectionOptions options, Messages.Result&lt;List&lt;String>> result) {"
-        errorLine2="      ~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="308"
-            column="7"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      VideoSelectionOptions options, Messages.Result&lt;List&lt;String>> result) {"
-        errorLine2="                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="308"
-            column="38"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      Messages.Result&lt;List&lt;String>> result) {"
-        errorLine2="      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="360"
-            column="7"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      Messages.Result&lt;List&lt;String>> result) {"
-        errorLine2="      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="372"
-            column="7"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      @NonNull ImageSelectionOptions options, Messages.Result&lt;List&lt;String>> result) {"
-        errorLine2="                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="421"
-            column="47"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="  public boolean onActivityResult(int requestCode, int resultCode, Intent data) {"
-        errorLine2="                                                                   ~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java"
-            line="541"
-            column="68"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="  public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) {"
-        errorLine2="                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java"
-            line="182"
-            column="35"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      Result&lt;List&lt;String>> result) {"
-        errorLine2="      ~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java"
-            line="308"
-            column="7"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="      Result&lt;List&lt;String>> result) {"
-        errorLine2="      ~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java"
-            line="338"
-            column="7"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="    void error(Throwable error);"
-        errorLine2="               ~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="509"
-            column="16"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="        Result&lt;List&lt;String>> result);"
-        errorLine2="        ~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="571"
-            column="9"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="        Result&lt;List&lt;String>> result);"
-        errorLine2="        ~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="583"
-            column="9"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="    static MessageCodec&lt;Object> getCodec() {"
-        errorLine2="           ~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="589"
-            column="12"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="    static void setup(BinaryMessenger binaryMessenger, ImagePickerApi api) {"
-        errorLine2="                      ~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="593"
-            column="23"/>
-    </issue>
-
-    <issue
-        id="UnknownNullness"
-        message="Unknown nullability; explicitly declare as `@Nullable` or `@NonNull` to improve Kotlin interoperability; see https://android.github.io/kotlin-guides/interop.html#nullability-annotations"
-        errorLine1="    static void setup(BinaryMessenger binaryMessenger, ImagePickerApi api) {"
-        errorLine2="                                                       ~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/io/flutter/plugins/imagepicker/Messages.java"
-            line="593"
-            column="56"/>
-    </issue>
-
-</issues>
diff --git a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java
index 6aa1181..4230885 100644
--- a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java
+++ b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java
@@ -95,7 +95,7 @@
     public final @Nullable VideoSelectionOptions videoOptions;
     public final @NonNull Messages.Result<List<String>> result;
 
-    private PendingCallState(
+    PendingCallState(
         @Nullable ImageSelectionOptions imageOptions,
         @Nullable VideoSelectionOptions videoOptions,
         @NonNull Messages.Result<List<String>> result) {
@@ -107,10 +107,10 @@
 
   @VisibleForTesting final String fileProviderName;
 
-  private final Activity activity;
-  @VisibleForTesting final File externalFilesDirectory;
-  private final ImageResizer imageResizer;
-  private final ImagePickerCache cache;
+  private final @NonNull Activity activity;
+  @VisibleForTesting final @NonNull File externalFilesDirectory;
+  private final @NonNull ImageResizer imageResizer;
+  private final @NonNull ImagePickerCache cache;
   private final PermissionManager permissionManager;
   private final FileUriResolver fileUriResolver;
   private final FileUtils fileUtils;
@@ -140,10 +140,10 @@
   private final Object pendingCallStateLock = new Object();
 
   public ImagePickerDelegate(
-      final Activity activity,
-      final File externalFilesDirectory,
-      final ImageResizer imageResizer,
-      final ImagePickerCache cache) {
+      final @NonNull Activity activity,
+      final @NonNull File externalFilesDirectory,
+      final @NonNull ImageResizer imageResizer,
+      final @NonNull ImagePickerCache cache) {
     this(
         activity,
         externalFilesDirectory,
@@ -181,12 +181,7 @@
                 activity,
                 new String[] {(imageUri != null) ? imageUri.getPath() : ""},
                 null,
-                new MediaScannerConnection.OnScanCompletedListener() {
-                  @Override
-                  public void onScanCompleted(String path, Uri uri) {
-                    listener.onPathReady(path);
-                  }
-                });
+                (path, uri) -> listener.onPathReady(path));
           }
         },
         new FileUtils(),
@@ -199,13 +194,13 @@
    */
   @VisibleForTesting
   ImagePickerDelegate(
-      final Activity activity,
-      final File externalFilesDirectory,
-      final ImageResizer imageResizer,
+      final @NonNull Activity activity,
+      final @NonNull File externalFilesDirectory,
+      final @NonNull ImageResizer imageResizer,
       final @Nullable ImageSelectionOptions pendingImageOptions,
       final @Nullable VideoSelectionOptions pendingVideoOptions,
       final @Nullable Messages.Result<List<String>> result,
-      final ImagePickerCache cache,
+      final @NonNull ImagePickerCache cache,
       final PermissionManager permissionManager,
       final FileUriResolver fileUriResolver,
       final FileUtils fileUtils,
@@ -290,7 +285,9 @@
   }
 
   public void chooseVideoFromGallery(
-      VideoSelectionOptions options, boolean usePhotoPicker, Messages.Result<List<String>> result) {
+      @NonNull VideoSelectionOptions options,
+      boolean usePhotoPicker,
+      @NonNull Messages.Result<List<String>> result) {
     if (!setPendingOptionsAndResult(null, options, result)) {
       finishWithAlreadyActiveError(result);
       return;
@@ -318,7 +315,7 @@
   }
 
   public void takeVideoWithCamera(
-      VideoSelectionOptions options, Messages.Result<List<String>> result) {
+      @NonNull VideoSelectionOptions options, @NonNull Messages.Result<List<String>> result) {
     if (!setPendingOptionsAndResult(null, options, result)) {
       finishWithAlreadyActiveError(result);
       return;
@@ -376,7 +373,7 @@
   public void chooseImageFromGallery(
       @NonNull ImageSelectionOptions options,
       boolean usePhotoPicker,
-      Messages.Result<List<String>> result) {
+      @NonNull Messages.Result<List<String>> result) {
     if (!setPendingOptionsAndResult(options, null, result)) {
       finishWithAlreadyActiveError(result);
       return;
@@ -388,7 +385,7 @@
   public void chooseMultiImageFromGallery(
       @NonNull ImageSelectionOptions options,
       boolean usePhotoPicker,
-      Messages.Result<List<String>> result) {
+      @NonNull Messages.Result<List<String>> result) {
     if (!setPendingOptionsAndResult(options, null, result)) {
       finishWithAlreadyActiveError(result);
       return;
@@ -436,7 +433,7 @@
   }
 
   public void takeImageWithCamera(
-      @NonNull ImageSelectionOptions options, Messages.Result<List<String>> result) {
+      @NonNull ImageSelectionOptions options, @NonNull Messages.Result<List<String>> result) {
     if (!setPendingOptionsAndResult(options, null, result)) {
       finishWithAlreadyActiveError(result);
       return;
@@ -556,7 +553,8 @@
   }
 
   @Override
-  public boolean onActivityResult(final int requestCode, final int resultCode, final Intent data) {
+  public boolean onActivityResult(
+      final int requestCode, final int resultCode, final @Nullable Intent data) {
     Runnable handlerRunnable;
 
     switch (requestCode) {
@@ -605,7 +603,7 @@
       } else {
         paths.add(fileUtils.getPathFromUri(activity, intent.getData()));
       }
-      handleMultiImageResult(paths, false);
+      handleMultiImageResult(paths);
       return;
     }
 
@@ -632,12 +630,7 @@
           localPendingCameraMediaUri != null
               ? localPendingCameraMediaUri
               : Uri.parse(cache.retrievePendingCameraMediaUriPath()),
-          new OnPathReadyListener() {
-            @Override
-            public void onPathReady(String path) {
-              handleImageResult(path, true);
-            }
-          });
+          path -> handleImageResult(path, true));
       return;
     }
 
@@ -652,12 +645,7 @@
           localPendingCameraMediaUrl != null
               ? localPendingCameraMediaUrl
               : Uri.parse(cache.retrievePendingCameraMediaUriPath()),
-          new OnPathReadyListener() {
-            @Override
-            public void onPathReady(String path) {
-              handleVideoResult(path);
-            }
-          });
+          this::handleVideoResult);
       return;
     }
 
@@ -665,8 +653,7 @@
     finishWithSuccess(null);
   }
 
-  private void handleMultiImageResult(
-      ArrayList<String> paths, boolean shouldDeleteOriginalIfScaled) {
+  private void handleMultiImageResult(ArrayList<String> paths) {
     ImageSelectionOptions localImageOptions = null;
     synchronized (pendingCallStateLock) {
       if (pendingCallState != null) {
@@ -678,13 +665,6 @@
       ArrayList<String> finalPath = new ArrayList<>();
       for (int i = 0; i < paths.size(); i++) {
         String finalImagePath = getResizedImagePath(paths.get(i), localImageOptions);
-
-        //delete original file if scaled
-        if (finalImagePath != null
-            && !finalImagePath.equals(paths.get(i))
-            && shouldDeleteOriginalIfScaled) {
-          new File(paths.get(i)).delete();
-        }
         finalPath.add(i, finalImagePath);
       }
       finishWithListSuccess(finalPath);
@@ -693,7 +673,7 @@
     }
   }
 
-  private void handleImageResult(String path, boolean shouldDeleteOriginalIfScaled) {
+  void handleImageResult(String path, boolean shouldDeleteOriginalIfScaled) {
     ImageSelectionOptions localImageOptions = null;
     synchronized (pendingCallStateLock) {
       if (pendingCallState != null) {
@@ -721,7 +701,7 @@
         outputOptions.getQuality().intValue());
   }
 
-  private void handleVideoResult(String path) {
+  void handleVideoResult(String path) {
     finishWithSuccess(path);
   }
 
diff --git a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java
index cbf52bd..3307592 100644
--- a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java
+++ b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java
@@ -176,20 +176,18 @@
   }
 
   private FlutterPluginBinding pluginBinding;
-  private ActivityState activityState;
+  ActivityState activityState;
 
   @SuppressWarnings("deprecation")
-  public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
+  public static void registerWith(
+      @NonNull io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
     if (registrar.activity() == null) {
       // If a background flutter view tries to register the plugin, there will be no activity from the registrar,
       // we stop the registering process immediately because the ImagePicker requires an activity.
       return;
     }
     Activity activity = registrar.activity();
-    Application application = null;
-    if (registrar.context() != null) {
-      application = (Application) (registrar.context().getApplicationContext());
-    }
+    Application application = (Application) (registrar.context().getApplicationContext());
     ImagePickerPlugin plugin = new ImagePickerPlugin();
     plugin.setup(registrar.messenger(), application, activity, registrar, null);
   }
@@ -305,7 +303,7 @@
       @NonNull Messages.ImageSelectionOptions options,
       @NonNull Boolean allowMultiple,
       @NonNull Boolean usePhotoPicker,
-      Result<List<String>> result) {
+      @NonNull Result<List<String>> result) {
     ImagePickerDelegate delegate = getImagePickerDelegate();
     if (delegate == null) {
       result.error(
@@ -335,7 +333,7 @@
       @NonNull Messages.VideoSelectionOptions options,
       @NonNull Boolean allowMultiple,
       @NonNull Boolean usePhotoPicker,
-      Result<List<String>> result) {
+      @NonNull Result<List<String>> result) {
     ImagePickerDelegate delegate = getImagePickerDelegate();
     if (delegate == null) {
       result.error(
diff --git a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/Messages.java b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/Messages.java
index af98078..accf64b 100644
--- a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/Messages.java
+++ b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/Messages.java
@@ -1,7 +1,7 @@
 // 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.
-// Autogenerated from Pigeon (v9.1.0), do not edit directly.
+// Autogenerated from Pigeon (v9.2.5), do not edit directly.
 // See also: https://pub.dev/packages/pigeon
 
 package io.flutter.plugins.imagepicker;
@@ -39,7 +39,7 @@
   }
 
   @NonNull
-  private static ArrayList<Object> wrapError(@NonNull Throwable exception) {
+  protected static ArrayList<Object> wrapError(@NonNull Throwable exception) {
     ArrayList<Object> errorList = new ArrayList<Object>(3);
     if (exception instanceof FlutterError) {
       FlutterError error = (FlutterError) exception;
@@ -59,7 +59,7 @@
     REAR(0),
     FRONT(1);
 
-    private final int index;
+    final int index;
 
     private SourceCamera(final int index) {
       this.index = index;
@@ -70,7 +70,7 @@
     CAMERA(0),
     GALLERY(1);
 
-    private final int index;
+    final int index;
 
     private SourceType(final int index) {
       this.index = index;
@@ -81,7 +81,7 @@
     IMAGE(0),
     VIDEO(1);
 
-    private final int index;
+    final int index;
 
     private CacheRetrievalType(final int index) {
       this.index = index;
@@ -134,8 +134,8 @@
       this.quality = setterArg;
     }
 
-    /** Constructor is private to enforce null safety; use Builder. */
-    private ImageSelectionOptions() {}
+    /** Constructor is non-public to enforce null safety; use Builder. */
+    ImageSelectionOptions() {}
 
     public static final class Builder {
 
@@ -275,8 +275,8 @@
       this.camera = setterArg;
     }
 
-    /** Constructor is private to enforce null safety; use Builder. */
-    private SourceSpecification() {}
+    /** Constructor is non-public to enforce null safety; use Builder. */
+    SourceSpecification() {}
 
     public static final class Builder {
 
@@ -351,8 +351,8 @@
       this.message = setterArg;
     }
 
-    /** Constructor is private to enforce null safety; use Builder. */
-    private CacheRetrievalError() {}
+    /** Constructor is non-public to enforce null safety; use Builder. */
+    CacheRetrievalError() {}
 
     public static final class Builder {
 
@@ -446,8 +446,8 @@
       this.paths = setterArg;
     }
 
-    /** Constructor is private to enforce null safety; use Builder. */
-    private CacheRetrievalResult() {}
+    /** Constructor is non-public to enforce null safety; use Builder. */
+    CacheRetrievalResult() {}
 
     public static final class Builder {
 
@@ -504,9 +504,10 @@
   }
 
   public interface Result<T> {
+    @SuppressWarnings("UnknownNullness")
     void success(T result);
 
-    void error(Throwable error);
+    void error(@NonNull Throwable error);
   }
 
   private static class ImagePickerApiCodec extends StandardMessageCodec {
@@ -568,7 +569,7 @@
         @NonNull ImageSelectionOptions options,
         @NonNull Boolean allowMultiple,
         @NonNull Boolean usePhotoPicker,
-        Result<List<String>> result);
+        @NonNull Result<List<String>> result);
     /**
      * Selects video and returns their paths.
      *
@@ -580,17 +581,17 @@
         @NonNull VideoSelectionOptions options,
         @NonNull Boolean allowMultiple,
         @NonNull Boolean usePhotoPicker,
-        Result<List<String>> result);
+        @NonNull Result<List<String>> result);
     /** Returns results from a previous app session, if any. */
     @Nullable
     CacheRetrievalResult retrieveLostResults();
 
     /** The codec used by ImagePickerApi. */
-    static MessageCodec<Object> getCodec() {
+    static @NonNull MessageCodec<Object> getCodec() {
       return ImagePickerApiCodec.INSTANCE;
     }
     /** Sets up an instance of `ImagePickerApi` to handle messages through the `binaryMessenger`. */
-    static void setup(BinaryMessenger binaryMessenger, ImagePickerApi api) {
+    static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImagePickerApi api) {
       {
         BasicMessageChannel<Object> channel =
             new BasicMessageChannel<>(
diff --git a/packages/image_picker/image_picker_android/lib/src/messages.g.dart b/packages/image_picker/image_picker_android/lib/src/messages.g.dart
index c0506ad..a4f15c8 100644
--- a/packages/image_picker/image_picker_android/lib/src/messages.g.dart
+++ b/packages/image_picker/image_picker_android/lib/src/messages.g.dart
@@ -1,7 +1,7 @@
 // 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.
-// Autogenerated from Pigeon (v9.1.0), do not edit directly.
+// Autogenerated from Pigeon (v9.2.5), do not edit directly.
 // See also: https://pub.dev/packages/pigeon
 // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
 
diff --git a/packages/image_picker/image_picker_android/pubspec.yaml b/packages/image_picker/image_picker_android/pubspec.yaml
index da3f364..b259ab8 100755
--- a/packages/image_picker/image_picker_android/pubspec.yaml
+++ b/packages/image_picker/image_picker_android/pubspec.yaml
@@ -3,7 +3,7 @@
 repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_android
 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
 
-version: 0.8.6+13
+version: 0.8.6+14
 
 environment:
   sdk: ">=2.18.0 <4.0.0"
@@ -28,4 +28,4 @@
   flutter_test:
     sdk: flutter
   mockito: 5.4.0
-  pigeon: ^9.1.0
+  pigeon: ^9.2.5
diff --git a/packages/image_picker/image_picker_android/test/test_api.g.dart b/packages/image_picker/image_picker_android/test/test_api.g.dart
index aa5c38f..dbb6b14 100644
--- a/packages/image_picker/image_picker_android/test/test_api.g.dart
+++ b/packages/image_picker/image_picker_android/test/test_api.g.dart
@@ -1,7 +1,7 @@
 // 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.
-// Autogenerated from Pigeon (v9.1.0), do not edit directly.
+// Autogenerated from Pigeon (v9.2.5), do not edit directly.
 // See also: https://pub.dev/packages/pigeon
 // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import
 // ignore_for_file: avoid_relative_lib_imports
@@ -57,6 +57,8 @@
 }
 
 abstract class TestHostImagePickerApi {
+  static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding =>
+      TestDefaultBinaryMessengerBinding.instance;
   static const MessageCodec<Object?> codec = _TestHostImagePickerApiCodec();
 
   /// Selects images and returns their paths.
@@ -83,9 +85,12 @@
           'dev.flutter.pigeon.ImagePickerApi.pickImages', codec,
           binaryMessenger: binaryMessenger);
       if (api == null) {
-        channel.setMockMessageHandler(null);
+        _testBinaryMessengerBinding!.defaultBinaryMessenger
+            .setMockDecodedMessageHandler<Object?>(channel, null);
       } else {
-        channel.setMockMessageHandler((Object? message) async {
+        _testBinaryMessengerBinding!.defaultBinaryMessenger
+            .setMockDecodedMessageHandler<Object?>(channel,
+                (Object? message) async {
           assert(message != null,
               'Argument for dev.flutter.pigeon.ImagePickerApi.pickImages was null.');
           final List<Object?> args = (message as List<Object?>?)!;
@@ -114,9 +119,12 @@
           'dev.flutter.pigeon.ImagePickerApi.pickVideos', codec,
           binaryMessenger: binaryMessenger);
       if (api == null) {
-        channel.setMockMessageHandler(null);
+        _testBinaryMessengerBinding!.defaultBinaryMessenger
+            .setMockDecodedMessageHandler<Object?>(channel, null);
       } else {
-        channel.setMockMessageHandler((Object? message) async {
+        _testBinaryMessengerBinding!.defaultBinaryMessenger
+            .setMockDecodedMessageHandler<Object?>(channel,
+                (Object? message) async {
           assert(message != null,
               'Argument for dev.flutter.pigeon.ImagePickerApi.pickVideos was null.');
           final List<Object?> args = (message as List<Object?>?)!;
@@ -145,9 +153,12 @@
           'dev.flutter.pigeon.ImagePickerApi.retrieveLostResults', codec,
           binaryMessenger: binaryMessenger);
       if (api == null) {
-        channel.setMockMessageHandler(null);
+        _testBinaryMessengerBinding!.defaultBinaryMessenger
+            .setMockDecodedMessageHandler<Object?>(channel, null);
       } else {
-        channel.setMockMessageHandler((Object? message) async {
+        _testBinaryMessengerBinding!.defaultBinaryMessenger
+            .setMockDecodedMessageHandler<Object?>(channel,
+                (Object? message) async {
           // ignore message
           final CacheRetrievalResult? output = api.retrieveLostResults();
           return <Object?>[output];