Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: type 'Null' is not a subtype of type 'String' in type cast on v.5.2.0 only on iOS #738

Closed
akarapetsas opened this issue Jun 25, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@akarapetsas
Copy link

‼️ Required data ‼️

Do not remove any of the steps from the template below. If a step is not applicable to your issue, please leave that step empty.

There are a lot of things that can contribute to things not working. Having a very basic understanding of your environment will help us understand your issue faster!

Environment

  • [ ✓] Output of flutter doctor
    [✓] Flutter (Channel stable, 3.10.5, on macOS 13.4 22F66 darwin-arm64, locale en-DE)
    • Flutter version 3.10.5 on channel stable at /opt/homebrew/Caskroom/flutter/3.7.6/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (11 days ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/alexioskarapetsas/Library/Android/sdk
• Platform android-33, build-tools 33.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.0

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

[✓] Android Studio (version 2022.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.6+0-17.0.6b802.4-9586694)

[✓] Connected device (3 available)
• iPhone (mobile) • 00008101-000649190198001E • ios • iOS 16.5.1 20F75
• macOS (desktop) • macos • darwin-arm64 • macOS 13.4 22F66 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 114.0.5735.133

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

• No issues found!
Process finished with exit code 0

  • [✓] Version of purchases-flutter => 5.2.0
  • [✓] Testing device version e.g.: iOS 16.5.1
  • [✓ ] How often the issue occurs- every one of your customers is impacted? Only in dev? Constantly both on dev and prod
  • [✓ ] Debug logs that reproduce the issue
  • [✓ ] Steps to reproduce, with a description of expected vs. actual behavior
    Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

Stacktrace:
2023-06-25 10:28:04.722650+0200 Runner[2247:349369] [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'String' in type cast
#0 new LinkedHashMap.from. (dart:collection/linked_hash_map.dart:187)
#1 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625)
#2 new LinkedHashMap.from (dart:collection/linked_hash_map.dart:186)
#3 _$$_CustomerInfoFromJson (package:purchases_flutter/models/customer_info_wrapper.g.dart:12)
#4 new _$_CustomerInfo.fromJson (package:purchases_flutter/models/customer_info_wrapper.freezed.dart:332)
#5 _$CustomerInfoFromJson (package:purchases_flutter/models/customer_info_wrapper.freezed.dart:18)
#6 new CustomerInfo.fromJson (package:purchases_flutter/models/customer_info_wrapper.dart:66)
#7 Purchases.getCustomerInfo (package:purchases_flutter/purchases_flutter.dart:561)

#8 Payments.isUserPremium (package:flutter_app/utils/payments.dart:23)

#9 Utils.canAccessContent (package:flutter_app/utils/utils.dart:16)

#10 _ContentRowWidgetState.build.. (package:flutter_app/utils/column_audio_list.dart:77)

Describe the bug

I've updated the purchases_flutter package and I constantly get the exception described on the stacktrace above. And I can't get the info for the user on iOS (if has bought subscription etc). On android it works fine though.

Additional context

Add any other context about the problem here.

@akarapetsas akarapetsas added the bug Something isn't working label Jun 25, 2023
@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@akarapetsas
Copy link
Author

Downgrading to version 4.13.0 of purchases_flutter resolves the issue

@reimager
Copy link

Thank you for posting this. I was really heading down the rabbit hole.
I have the same issue, only on IOS, but 5.2.0 does not seem to be available on android?

For me I just had to change pubspec.yaml to "5.1.0" not "^5.1.0" to avoid 5.2.0

@tonidero
Copy link
Contributor

Hi @akarapetsas, thanks for reporting this! We've been able to confirm the issue in our 5.2.0 SDK and are working on a fix. In the meantime, we suggest making sure you're using 5.1.0 or a previous version. Will update this issue once the release is out!

tonidero added a commit to RevenueCat/purchases-ios that referenced this issue Jun 26, 2023
### Description 
Reported in RevenueCat/purchases-flutter#738. 

After #2654, we were
using the new Google Play identifiers that include the plan id in
expiration dates, but we didn't change the system that parses purchase
dates. Later on, when we map purchases, we iterate over the expiration
dates map, and since that id wasn't found in the purchase dates, it was
null, causing the issue in flutter.

This makes the purchase date calculation use the same algorithm that we
use for expiration dates to get the new google play product identifiers.
@tonidero
Copy link
Contributor

Hi @akarapetsas and @reimager. We narrowed down the issue to users with android purchases using the app in iOS. We just released version 5.2.1 of the flutter SDK which solves this issue. Please try it and let us know the results!

@reimager
Copy link

I can confirm that 5.2.1 has solved the issue for me! Thank you!

I don't know if the users I was testing with had any purchases on android, but I certainly test with same users on both so possibly in the past. Regardless, I have no exceptions now on IOS.

@tonidero
Copy link
Contributor

Yeah, it can happen with purchases in the past. Glad that it worked for you!

I'm going to close this but please reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants