-
Notifications
You must be signed in to change notification settings - Fork 179
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
Fix wrong type purchase package purchase product #301
Conversation
lib/purchases_flutter.dart
Outdated
@@ -628,6 +635,32 @@ class Purchases { | |||
/// Android only. Call close when you are done with this instance of Purchases to disconnect | |||
/// from the billing services and clean up resources | |||
static Future<void> close() => _channel.invokeMethod('close'); | |||
|
|||
static Future<Map<String, dynamic>> | |||
_invokeMethodReturningPurchaserInfoJsonFromMap( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better names accepted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could just be invokeMethodReturningPurchaserInfoJson
. but maybe we can also just call invokeMethodReturningMap
here, and then have a method getPurchaserInfoJsonFromMap
or something, to separate out the two pieces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked the idea of extracting _getPurchaserInfoJsonFromMap
. Checkout the latest commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great! left minor suggestions, they can go into a follow-up PR too
method, | ||
arguments, | ||
); | ||
final response = Map<String, dynamic>.from(result!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can log if result is nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will crash, and I think it should crash because something is very wrong if there's no result, so I don't think logging is necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i agree it should crash, just seems like we sometimes don't get the most descriptive error messages. i suppose using the ! should give us a clear message though
d4c24a5
to
aa04b53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚡
* run codegen.sh * fix purchasePackage and purchaseProduct * fix discounted versions * use [dynamic arguments] * ignore trailing commas * some rename + refactor
[sc-12529]
Fixes #300
This line https://github.com/RevenueCat/purchases-flutter/pull/270/files#diff-2a88ebe6bbbad2ced268a39ea09b1e2d0553678f4e1e43bc8ed79a31c3b3921bL73 changed from
Map<dynamic, dynamic>
toMap<String, dynamic>
.It would have been caught by tests, but it's a shame we didn't have tests for such crucial functions. I added some tests for the fixed functions and will follow up with a PR making sure all functions are tested to prevent this from happening again. I want to release ASAP.