Skip to content

in_app_purchase : Null check operator used on a null value #154047

Closed
flutter/packages
#7515

Description

@LingLuoJack

Steps to reproduce

Hello, when I use in_app_purchase: ^3.2.0, an error occurs on the iPhone Mini 12.
The method that causes the error is queryProductDetails(). Please let me know how to resolve this issue.

Expected results

I hope the purchase dialog can pop up correctly。

Actual results

Null check operator used on a null value
image
this is stacktrace:
#0 SKProductMessage.decode (package:in_app_purchase_storekit/src/messages.g.dart:371:38)
#1 _InAppPurchaseAPICodec.readValueOfType (package:in_app_purchase_storekit/src/messages.g.dart:556:33)
#2 StandardMessageCodec.readValue (package:flutter/src/services/message_codecs.dart:477:12)
#3 StandardMessageCodec.readValueOfType (package:flutter/src/services/message_codecs.dart:522:23)
#4 _InAppPurchaseAPICodec.readValueOfType (package:in_app_purchase_storekit/src/messages.g.dart:564:22)
#5 StandardMessageCodec.readValue (package:flutter/src/services/message_codecs.dart:477:12)
#6 StandardMessageCodec.readValueOfType (package:flutter/src/services/message_codecs.dart:522:23)
#7 _InAppPurchaseAPICodec.readValueOfType (package:in_app_purchase_storekit/src/messages.g.dart:564:22)
#8 StandardMessageCodec.readValue (package:flutter/src/services/message_codecs.dart:477:12)
#9 _InAppPurchaseAPICodec.readValueOfType (package:in_app_purchase_storekit/src/messages.g.dart:560:49)
#10 StandardMessageCodec.readValue (package:flutter/src/services/message_codecs.dart:477:12)
#11 StandardMessageCodec.readValueOfType (package:flutter/src/services/message_codecs.dart:522:23)
#12 _InAppPurchaseAPICodec.readValueOfType (package:in_app_purchase_storekit/src/messages.g.dart:564:22)
#13 StandardMessageCodec.readValue (package:flutter/src/services/message_codecs.dart:477:12)
#14 StandardMessageCodec.decodeMessage (package:flutter/src/services/message_codecs.dart:341:28)
#15 BasicMessageChannel.send (package:flutter/src/services/platform_channel.dart:218:18)

#16 InAppPurchaseAPI.startProductRequest (package:in_app_purchase_storekit/src/messages.g.dart:703:47)

#17 SKRequestMaker.startProductRequest (package:in_app_purchase_storekit/src/store_kit_wrappers/sk_request_maker.dart:32:9)

#18 InAppPurchaseStoreKitPlatform.queryProductDetails (package:in_app_purchase_storekit/src/in_app_purchase_storekit_platform.dart:126:18)

#19 IapPay.purchase (package:aloha_pay/iap_pay/iap_pay.dart:66:31)

Code sample

final bool isAvailable = await _inAppPurchase.isAvailable(); if (!isAvailable) { return; } if (Platform.isIOS) { final InAppPurchaseStoreKitPlatformAddition iosPlatformAddition = _inAppPurchase.getPlatformAddition<InAppPurchaseStoreKitPlatformAddition>(); await iosPlatformAddition.setDelegate(ExamplePaymentQueueDelegate()); } ProductDetailsResponse? productDetailResponse; try { productDetailResponse = await _inAppPurchase.queryProductDetails([productId.trim()].toSet()); } catch (e) { }

Screenshots or Video

image

Logs

No response

Flutter Doctor output

[✓] Flutter (Channel stable, 3.22.2, on macOS 13.6.6 22G630 darwin-arm64, locale zh-Hans-CN)
• Flutter version 3.22.2 on channel stable at /Users/cross/Documents/FlutterSdk/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 761747b (3 months ago), 2024-06-05 22:15:13 +0200
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/cross/Library/Android/sdk
✗ cmdline-tools component is missing
Run path/to/sdkmanager --install "cmdline-tools;latest"
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
• Android Studio at /Applications/Android Studio.app/Contents
• 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 17.0.9+0-17.0.9b1087.7-11185874)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.2.0.2)
• IntelliJ at /Applications/IntelliJ IDEA.app
• 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

[✓] Connected device (4 available)
• 12mini (mobile) • 00008101-001E19603A44001E • ios • iOS 14.2 18B92
• macOS (desktop) • macos • darwin-arm64 • macOS 13.6.6 22G630 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 13.6.6 22G630 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.120
! Error: Browsing on the local area network for 袁刚的iPhone. Ensure the device is unlocked and attached with a cable or
associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
• All expected network resources are available.

! Doctor found issues in 1 category.

Activity

  1. stuartmorgan-g commented on Aug 24, 2024

    @stuartmorgan-g
    Contributor

    #0 SKProductMessage.decode (package:in_app_purchase_storekit/src/messages.g.dart:371:38)

    That line is

    localizedDescription: result[2]! as String,

    And the conversion code is just setting it directly from the SKProduct's localizedDescription. It looks like the StoreKit header may be misrepresenting the nullability of localizedDescription, in which case the Pigeon structure will need to relax it to be nullable.

    /cc @LouiseHsu

  2. added
    c: crashStack traces logged to the console
    platform-iosiOS applications specifically
    packageflutter/packages repository. See also p: labels.
    team-iosOwned by iOS platform team
    on Aug 24, 2024
  3. github-actions commented on Sep 10, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: crashStack traces logged to the consolep: in_app_purchasePlugin for in-app purchasepackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions