Repository: flutter
Issue: Flutter app crashes if calling `GoogleMapController.takeSnapShot()` before layout complete
Labels: c: crash,platform-android,p: maps,package,P2,team-android,triaged-android

### Steps to reproduce

Using

* google_maps_flutter 2.6.0
* google_maps_flutter_android 2.7.0

if I run this code in a callback:

```dart
final GoogleMapController controller = await _mapControllerCompleter.future;
final mapImageSnapshot = await controller.takeSnapshot();
```

and the UI tree layout has not yet completed, the entire app crashes, with this exception:

```console
I/Google Maps Android API( 7700): Google Play services package version: 225014047
I/Google Maps Android API( 7700): Google Play services maps renderer version(legacy): 203115000
I/PlatformViewsController( 7700): Hosting view in a virtual display for platform view: 1
I/PlatformViewsController( 7700): PlatformView is using SurfaceProducer backend
I/GoogleMapController( 7700): No TextureView found. Likely using the LEGACY renderer.
W/wa      ( 7700): File created: _google_maps_sdk_crash_count_2
W/wa      ( 7700): Marker deleted: _google_maps_sdk_crash_count_1
W/wa      ( 7700): Couldn't create marker: _google_maps_sdk_crash_
D/HostConnection( 7700): createUnique: call
D/HostConnection( 7700): HostConnection::get() New Host Connection established 0x7242e1891090, tid 7989
E/AndroidRuntime( 7700): FATAL EXCEPTION: androidmapsapi-Snapshot
E/AndroidRuntime( 7700): Process: app.clicksocial, PID: 7700
E/AndroidRuntime( 7700): java.lang.IllegalArgumentException: width and height must be > 0
E/AndroidRuntime( 7700): 	at android.graphics.Bitmap.createBitmap(Bitmap.java:1111)
E/AndroidRuntime( 7700): 	at android.graphics.Bitmap.createBitmap(Bitmap.java:1078)
E/AndroidRuntime( 7700): 	at android.graphics.Bitmap.createBitmap(Bitmap.java:1028)
E/AndroidRuntime( 7700): 	at android.graphics.Bitmap.createBitmap(Bitmap.java:989)
E/AndroidRuntime( 7700): 	at com.google.maps.api.android.lib6.impl.a.d(:com.google.android.gms.dynamite_mapsdynamite@225014047@22.50.14 (190800-0):2)
E/AndroidRuntime( 7700): 	at com.google.maps.api.android.lib6.impl.bh.run(:com.google.android.gms.dynamite_mapsdynamite@225014047@22.50.14 (190800-0):1)
E/AndroidRuntime( 7700): 	at java.lang.Thread.run(Thread.java:1012)
W/Parcel  ( 7700): Expecting binder but got null!
I/Process ( 7700): Sending signal. PID: 7700 SIG: 9
Lost connection to device.
```

I understand why the failure is happening, but this should not crash the whole app! At worst, an exception should be thrown back in the Dart code, or a `null` value should be returned.


### Expected results

A Java exception should not crash the Flutter runtime, ever! This is horrible behavior.

### Actual results

A Java exception takes down the whole Flutter app.

### Code sample

--

### Screenshots or Video

--

### Logs

--

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
$ flutter doctor -v
[✓] Flutter (Channel main, 3.21.0-16.0.pre.11, on Fedora Linux 39 (Workstation Edition) 6.7.7-200.fc39.x86_64, locale en_US.utf8)
    • Flutter version 3.21.0-16.0.pre.11 on channel main at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6807eacb33 (4 days ago), 2024-03-27 18:31:44 -0400
    • Engine revision 73c145c9ac
    • Dart version 3.4.0 (build 3.4.0-279.0.dev)
    • DevTools version 2.34.0-dev.12

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /home/luke/Android/Sdk
    • Platform android-34, build-tools 33.0.1
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 17.0.6 (Fedora 17.0.6-2.fc39)
    • cmake version 3.27.7
    • ninja version 1.11.1
    • pkg-config version 1.9.5

[✓] Android Studio (version 2022.2)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 73.0.2
    • Dart plugin version 222.4582
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.87.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.85.20240301

[✓] VS Code (version 1.88.0-insider)
    • VS Code at /usr/share/code-insiders
    • Flutter extension version 3.79.20231130

[✓] Connected device (3 available)
    • sdk gphone x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Linux (desktop)            • linux         • linux-x64      • Fedora Linux 39 (Workstation Edition) 6.7.7-200.fc39.x86_64
    • Chrome (web)               • chrome        • web-javascript • Google Chrome 122.0.6261.94

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>