Repository: flutter
Issue: Calling VirtualDisplayController::resize() just before VirtualDisplayController::dispose() causes a crash
Labels: platform-android,a: platform-views,P2,needs repro info,team-android,triaged-android

### Steps to reproduce

In PlatformViewsController.java, there is a channelHandler object that implements the PlatformViewsChannel.PlatformViewsHandler interface. This interface includes two methods: resize() and dispose(). If resize() is called immediately before dispose(), it may lead to a crash.

1) When resize() is called with viewId = 0, it triggers a call to vdController.resize(). This call includes a Runnable object (lambda) as its third parameter, which is added to the message queue using View::postDelayed().
![1](https://github.com/user-attachments/assets/673e9dfe-0ca8-4bd7-aa8e-20f38dbc6921)
![2](https://github.com/user-attachments/assets/c16810fe-9bd5-47c9-8910-48e08b45deac)
![3](https://github.com/user-attachments/assets/8b4a53a0-24b9-440a-8203-dd67b4b71f1d)

2) Then we call the dispose() function, which invokes vdController.dispose() and removes vdController from the HashMap.
![4](https://github.com/user-attachments/assets/1599facb-2fd6-4252-98f4-5281357153d1)

3) After calling dispose(), the lambda previously added to the message queue using View::postDelayed() begins execution. Here, we attempt to retrieve the dimensions of the render target: vdController.getRenderTargetWidth(), vdController.getRenderTargetHeight().
![5](https://github.com/user-attachments/assets/c3f4fd33-64cc-4f59-b954-294dfc6ee8b1)

4) In VirtualDisplayController::getRenderTargetWidth() we call renderTarget.getWidth()
![6](https://github.com/user-attachments/assets/75f7f32e-ac9c-44ec-94b0-2da9508879eb)

5) Inside the SurfaceProducerPlatformViewRenderTarget, the producer object was released when vdController.dispose() was called, resulting in producer being null.
![7](https://github.com/user-attachments/assets/1994bf72-e83e-41e4-8169-7115fb5719ac)

### Expected results

Calling VirtualDisplayController::resize() just before VirtualDisplayController::dispose() shouldn't cause a crash

### Actual results

The app is crashed.

### Code sample

<details open><summary>Code sample</summary>

No code. This issue is obvious from the attached screenshots of Flutter code from the steps to reproduce section.

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details>
<summary>Crash log</summary>

```

08-02 15:25:22.167 18044 18044 E AndroidRuntime: FATAL EXCEPTION: main
08-02 15:25:22.167 18044 18044 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'int io.flutter.view.TextureRegistry$SurfaceProducer.getWidth()' on a null object reference
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at io.flutter.plugin.platform.SurfaceProducerPlatformViewRenderTarget.getWidth(SurfaceProducerPlatformViewRenderTarget.java:25)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at io.flutter.plugin.platform.VirtualDisplayController.getRenderTargetWidth(VirtualDisplayController.java:132)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at io.flutter.plugin.platform.PlatformViewsController$1.lambda$resize$0$io-flutter-plugin-platform-PlatformViewsController$1(PlatformViewsController.java:352)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at io.flutter.plugin.platform.PlatformViewsController$1$$ExternalSyntheticLambda0.run(Unknown Source:8)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:958)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:230)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:319)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:8919)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
08-02 15:25:22.167 18044 18044 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

```

</details>

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[Paste your output here]
```

</details>