Repository: flutter
Issue: [in_app_purchase] java.lang.NullPointerException on debug console
Labels: c: crash,platform-android,p: in_app_purchase,package,has reproducible steps,P2,team-android,triaged-android,found in release: 3.24

### What package does this bug report belong to?

in_app_purchase

### What target platforms are you seeing this bug on?

Android

### Have you already upgraded your packages?

Yes

### Dependency versions

```
dependencies:
  flutter:
    sdk: flutter
  in_app_purchase: ^3.2.0
```

### Steps to reproduce

1. The error only throwed on a purchase subscribed or close window without subscribed

### Expected results

Even I try it with using Subscription Stream, it showing me up same issues.

### Actual results

When I click on Subscribe button, it open a subscribe window like image. Now if close this window by clicking outside of the window or even when I subscribe it, then the of closing the window, the error is thrown on debug console.

I didn't write huge code, just install the package, initialize it and get products then handler. I do not do anything on my android folder.

The error is like the second image.

### Code sample

```
class _SubscriptionPageState extends State<SubscriptionPage> {
  final InAppPurchase _inAppPurchase = InAppPurchase.instance;

  //Product Listing
  static const List<String> _productIds = ['com....subscription'];

  Future<Subscription> getProducts() async {
    final bool isAvailable = await _inAppPurchase.isAvailable();
    if (!isAvailable) {
      return Subscription(
        isAvailable: isAvailable,
        products: [],
        notFoundIds: [],
      );
    }
    final ProductDetailsResponse productDetailResponse =
        await _inAppPurchase.queryProductDetails(_productIds.toSet());

    if (productDetailResponse.error != null) {
      throw Exception(productDetailResponse.error!.message);
    }
    return Subscription(
      isAvailable: isAvailable,
      products: productDetailResponse.productDetails,
      notFoundIds: productDetailResponse.notFoundIDs,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: QueryBuilder(
        query: Query(
          key: ['subscription'],
          queryFn: () => getProducts(),
          config: QueryConfig(
            storeQuery: false,
            cacheDuration: const Duration(milliseconds: 500),
          ),
        ),
        builder: (context, state) {
          final product = state.data!.products[0];
          return BasicAppButton(
            title: 'Subscribe',
            onPressed: () {
              final PurchaseParam param = GooglePlayPurchaseParam(
                productDetails: product,
                changeSubscriptionParam: null,
              );
              _inAppPurchase.buyNonConsumable(
                purchaseParam: param,
              );
            },
            level: '3',
          );
        },
      ),
    );
  }
}
```

### Screenshots or Videos


![image](https://github.com/user-attachments/assets/80146027-c300-49ab-bcb2-ee88dbf4aad4)


### Logs

![image (1)](https://github.com/user-attachments/assets/13fe5c2c-255a-402e-aacb-a32e2fe1a12e)

### Flutter Doctor output

![image](https://github.com/user-attachments/assets/441e3bee-a1f7-4392-9ece-f2dd165b5f34)