[image_picker][android] Non-bitmap images now return path instead of null (#3590)

## Description
This PR now returns the path of unsupported files(non-bitmap images) instead of null. Now the user can decide himself what to do with the path of the unsupported image. Example file showcases how to display an error placeholder whenever an unsupported image type is selected.

## Issues

Fixes flutter/flutter#88461
diff --git a/packages/image_picker/image_picker/CHANGELOG.md b/packages/image_picker/image_picker/CHANGELOG.md
index 7b9dd7c..aeb5437 100644
--- a/packages/image_picker/image_picker/CHANGELOG.md
+++ b/packages/image_picker/image_picker/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.8.7+3
+
+* Adds handling of unsupported image types to the example.
+
 ## 0.8.7+2
 
 * Updates minimum Flutter version to 3.3.
diff --git a/packages/image_picker/image_picker/example/lib/main.dart b/packages/image_picker/image_picker/example/lib/main.dart
index f4bd7c3..247c0a9 100755
--- a/packages/image_picker/image_picker/example/lib/main.dart
+++ b/packages/image_picker/image_picker/example/lib/main.dart
@@ -189,7 +189,13 @@
               label: 'image_picker_example_picked_image',
               child: kIsWeb
                   ? Image.network(_imageFileList![index].path)
-                  : Image.file(File(_imageFileList![index].path)),
+                  : Image.file(
+                      File(_imageFileList![index].path),
+                      errorBuilder: (BuildContext context, Object error,
+                              StackTrace? stackTrace) =>
+                          const Center(
+                              child: Text('This image type is not supported')),
+                    ),
             );
           },
           itemCount: _imageFileList!.length,
diff --git a/packages/image_picker/image_picker/pubspec.yaml b/packages/image_picker/image_picker/pubspec.yaml
index 129444e..6c5f52b 100755
--- a/packages/image_picker/image_picker/pubspec.yaml
+++ b/packages/image_picker/image_picker/pubspec.yaml
@@ -3,7 +3,7 @@
   library, and taking new pictures with the camera.
 repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker
 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
-version: 0.8.7+2
+version: 0.8.7+3
 
 environment:
   sdk: ">=2.18.0 <4.0.0"
diff --git a/packages/image_picker/image_picker_android/CHANGELOG.md b/packages/image_picker/image_picker_android/CHANGELOG.md
index 629497f..6324d84 100644
--- a/packages/image_picker/image_picker_android/CHANGELOG.md
+++ b/packages/image_picker/image_picker_android/CHANGELOG.md
@@ -1,5 +1,6 @@
-## NEXT
+## 0.8.6+7
 
+* Fixes handling of non-bitmap image types.
 * Updates minimum Flutter version to 3.3.
 
 ## 0.8.6+6
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 9b35588..eaee6e8 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
@@ -392,7 +392,6 @@
       pickImageIntent = new Intent(Intent.ACTION_GET_CONTENT);
       pickImageIntent.setType("image/*");
     }
-
     activity.startActivityForResult(pickImageIntent, REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY);
   }
 
diff --git a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImageResizer.java b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImageResizer.java
index e65f0ad..5d0d5d8 100644
--- a/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImageResizer.java
+++ b/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/ImageResizer.java
@@ -32,7 +32,7 @@
       String imagePath, @Nullable Double maxWidth, @Nullable Double maxHeight, int imageQuality) {
     Bitmap bmp = decodeFile(imagePath);
     if (bmp == null) {
-      return null;
+      return imagePath;
     }
     boolean shouldScale = maxWidth != null || maxHeight != null || imageQuality < 100;
     if (!shouldScale) {
diff --git a/packages/image_picker/image_picker_android/android/src/test/java/io/flutter/plugins/imagepicker/ImageResizerTest.java b/packages/image_picker/image_picker_android/android/src/test/java/io/flutter/plugins/imagepicker/ImageResizerTest.java
index 2287c4a..45b2a45 100644
--- a/packages/image_picker/image_picker_android/android/src/test/java/io/flutter/plugins/imagepicker/ImageResizerTest.java
+++ b/packages/image_picker/image_picker_android/android/src/test/java/io/flutter/plugins/imagepicker/ImageResizerTest.java
@@ -6,6 +6,7 @@
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertNotNull;
 
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
@@ -16,6 +17,8 @@
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.junit.runner.RunWith;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 
@@ -26,6 +29,7 @@
 
   ImageResizer resizer;
   File imageFile;
+  File svgImageFile;
   File externalDirectory;
   Bitmap originalImageBitmap;
 
@@ -35,6 +39,7 @@
   public void setUp() throws IOException {
     mockCloseable = MockitoAnnotations.openMocks(this);
     imageFile = new File(getClass().getClassLoader().getResource("pngImage.png").getFile());
+    svgImageFile = new File(getClass().getClassLoader().getResource("flutter_image.svg").getFile());
     originalImageBitmap = BitmapFactory.decodeFile(imageFile.getPath());
     TemporaryFolder temporaryFolder = new TemporaryFolder();
     temporaryFolder.create();
@@ -78,4 +83,23 @@
     String outputFile = invalidResizer.resizeImageIfNeeded(imageFile.getPath(), null, 50.0, 100);
     assertThat(outputFile, equalTo(nonExistentDirectory.getPath() + "/scaled_pngImage.png"));
   }
+
+  @Test
+  public void onResizeImageIfNeeded_whenImagePathIsNotBitmap_shouldReturnPathAndNotNull() {
+    String nonBitmapImagePath = svgImageFile.getPath();
+
+    // Mock the static method
+    try (MockedStatic<BitmapFactory> mockedBitmapFactory =
+        Mockito.mockStatic(BitmapFactory.class)) {
+      // Configure the method to return null when called with a non-bitmap image
+      mockedBitmapFactory
+          .when(() -> BitmapFactory.decodeFile(nonBitmapImagePath, null))
+          .thenReturn(null);
+
+      String resizedImagePath = resizer.resizeImageIfNeeded(nonBitmapImagePath, null, null, 100);
+
+      assertNotNull(resizedImagePath);
+      assertThat(resizedImagePath, equalTo(nonBitmapImagePath));
+    }
+  }
 }
diff --git a/packages/image_picker/image_picker_android/android/src/test/resources/flutter_image.svg b/packages/image_picker/image_picker_android/android/src/test/resources/flutter_image.svg
new file mode 100644
index 0000000..ec3d914
--- /dev/null
+++ b/packages/image_picker/image_picker_android/android/src/test/resources/flutter_image.svg
@@ -0,0 +1,20 @@
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 166 202">
+    <defs>
+        <linearGradient id="triangleGradient">
+            <stop offset="20%" stop-color="#000000" stop-opacity=".55" />
+            <stop offset="85%" stop-color="#616161" stop-opacity=".01" />
+        </linearGradient>
+        <linearGradient id="rectangleGradient" x1="0%" x2="0%" y1="0%" y2="100%">
+            <stop offset="20%" stop-color="#000000" stop-opacity=".15" />
+            <stop offset="85%" stop-color="#616161" stop-opacity=".01" />
+        </linearGradient>
+    </defs>
+    <path fill="#42A5F5" fill-opacity=".8" d="M37.7 128.9 9.8 101 100.4 10.4 156.2 10.4"/>
+    <path fill="#42A5F5" fill-opacity=".8" d="M156.2 94 100.4 94 79.5 114.9 107.4 142.8"/>
+    <path fill="#0D47A1" d="M79.5 170.7 100.4 191.6 156.2 191.6 156.2 191.6 107.4 142.8"/>
+    <g transform="matrix(0.7071, -0.7071, 0.7071, 0.7071, -77.667, 98.057)">
+        <rect width="39.4" height="39.4" x="59.8" y="123.1" fill="#42A5F5" />
+        <rect width="39.4" height="5.5" x="59.8" y="162.5" fill="url(#rectangleGradient)" />
+    </g>
+    <path d="M79.5 170.7 120.9 156.4 107.4 142.8" fill="url(#triangleGradient)" />
+</svg>
\ No newline at end of file
diff --git a/packages/image_picker/image_picker_android/pubspec.yaml b/packages/image_picker/image_picker_android/pubspec.yaml
index 6c1c593..b1dad50 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+6
+version: 0.8.6+7
 
 environment:
   sdk: ">=2.18.0 <4.0.0"