Repository: flutter
Issue: InAppPurchase can't restore purchases in main
Labels: platform-android,p: in_app_purchase,package,team-ecosystem,has reproducible steps,P2,found in release: 3.3,found in release: 3.5,triaged-ecosystem

Plugin: in_app_purchase

My goal is, when starting the app, to restore purchases to check if the user has purchased the non-consumable product that allows him not to see the ads.

So in the main I restore the purchases, and immediately after that I manage the ads based on the purchase.

The problem is that if I launch the restore request from main, it tells me it can't find any products.
If, on the other hand, I launch the restore request in the app, it tells me that the product exists.


Code:
```
void main() {
  WidgetsFlutterBinding.ensureInitialized();

  final Stream purchaseUpdated = InAppPurchase.instance.purchaseStream;
  purchaseUpdated.listen((purchaseDetailsList) {
    _listenToPurchaseUpdated(purchaseDetailsList);
  });
  InAppPurchase.instance.restorePurchases();

  runApp(
    MyApp(),
  );
}

void _listenToPurchaseUpdated(List<PurchaseDetails> purchaseDetailsList) {
  print(purchaseDetailsList.length.toString());
}
```


**Expected results:** purchaseDetailsList.length.toString() isn't 0

**Actual results:** purchaseDetailsList.length.toString() is 0


Flutter doctor:
```
[√] Flutter (Channel stable, 3.3.2, on Microsoft Windows [Versione 10.0.19043.2006], locale it-IT)                                                              06], locale it-IT)
    • Flutter version 3.3.2 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e3c29ec00c (3 weeks ago), 2022-09-14 08:46:55 -0500    
    • Engine revision a4ff2c53d8
    • Dart version 2.18.1
    • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java      
    • Java version OpenJDK Runtime Environment (build
      11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.3)   
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community  
    • Visual Studio Community 2022 version 17.3.32825.248
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      11.0.12+7-b1504.28-7817840)

[√] VS Code (version 1.71.2)  
    • Flutter extension version 3.46.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Versione      10.0.19043.2006]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 106.0.5249.91    • Edge (web)        • edge    • web-javascript • Microsoft Edge
      105.0.1343.50

[√] HTTP Host Availability
    • All required HTTP hosts are available
```