Skip to content

Commit cc05af8

Browse files
authored
[in_app_purchase] fix skerror nullability (flutter#6139)
Should fix flutter#143177
1 parent dcbaee5 commit cc05af8

File tree

8 files changed

+25
-9
lines changed

8 files changed

+25
-9
lines changed

packages/in_app_purchase/in_app_purchase_storekit/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.11
2+
3+
* Fixes SKError.userInfo not being nullable.
4+
15
## 0.3.10
26

37
* Converts `startProductRequest()`, `finishTransaction()`, `restoreTransactions()`, `presentCodeRedemptionSheet()` to pigeon.

packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/messages.g.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ typedef NS_ENUM(NSUInteger, SKSubscriptionPeriodUnitMessage) {
146146
- (instancetype)init NS_UNAVAILABLE;
147147
+ (instancetype)makeWithCode:(NSInteger)code
148148
domain:(NSString *)domain
149-
userInfo:(NSDictionary<NSString *, id> *)userInfo;
149+
userInfo:(nullable NSDictionary<NSString *, id> *)userInfo;
150150
@property(nonatomic, assign) NSInteger code;
151151
@property(nonatomic, copy) NSString *domain;
152-
@property(nonatomic, copy) NSDictionary<NSString *, id> *userInfo;
152+
@property(nonatomic, copy, nullable) NSDictionary<NSString *, id> *userInfo;
153153
@end
154154

155155
@interface SKPaymentDiscountMessage : NSObject

packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/messages.g.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ - (NSArray *)toList {
218218
@implementation SKErrorMessage
219219
+ (instancetype)makeWithCode:(NSInteger)code
220220
domain:(NSString *)domain
221-
userInfo:(NSDictionary<NSString *, id> *)userInfo {
221+
userInfo:(nullable NSDictionary<NSString *, id> *)userInfo {
222222
SKErrorMessage *pigeonResult = [[SKErrorMessage alloc] init];
223223
pigeonResult.code = code;
224224
pigeonResult.domain = domain;

packages/in_app_purchase/in_app_purchase_storekit/lib/src/messages.g.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,14 @@ class SKErrorMessage {
195195
SKErrorMessage({
196196
required this.code,
197197
required this.domain,
198-
required this.userInfo,
198+
this.userInfo,
199199
});
200200

201201
int code;
202202

203203
String domain;
204204

205-
Map<String?, Object?> userInfo;
205+
Map<String?, Object?>? userInfo;
206206

207207
Object encode() {
208208
return <Object?>[
@@ -217,7 +217,7 @@ class SKErrorMessage {
217217
return SKErrorMessage(
218218
code: result[0]! as int,
219219
domain: result[1]! as String,
220-
userInfo: (result[2] as Map<Object?, Object?>?)!.cast<String?, Object?>(),
220+
userInfo: (result[2] as Map<Object?, Object?>?)?.cast<String?, Object?>(),
221221
);
222222
}
223223
}

packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_payment_queue_wrapper.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,10 @@ class SKError {
380380

381381
/// Converts [SKErrorMessage] into the dart equivalent
382382
static SKError convertFromPigeon(SKErrorMessage msg) {
383-
return SKError(code: msg.code, domain: msg.domain, userInfo: msg.userInfo);
383+
return SKError(
384+
code: msg.code,
385+
domain: msg.domain,
386+
userInfo: msg.userInfo ?? <String, Object>{});
384387
}
385388
}
386389

packages/in_app_purchase/in_app_purchase_storekit/pigeons/messages.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class SKErrorMessage {
9191

9292
final int code;
9393
final String domain;
94-
final Map<String?, Object?> userInfo;
94+
final Map<String?, Object?>? userInfo;
9595
}
9696

9797
class SKPaymentDiscountMessage {

packages/in_app_purchase/in_app_purchase_storekit/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: in_app_purchase_storekit
22
description: An implementation for the iOS and macOS platforms of the Flutter `in_app_purchase` plugin. This uses the StoreKit Framework.
33
repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_storekit
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
5-
version: 0.3.10
5+
version: 0.3.11
66

77
environment:
88
sdk: ^3.2.3

packages/in_app_purchase/in_app_purchase_storekit/test/store_kit_wrappers/pigeon_converter_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,13 @@ void main() {
9595
SkProductResponseWrapper.convertFromPigeon(msg);
9696
expect(convertedWrapper, productResponse);
9797
});
98+
99+
test('test SKerror pigeon converter', () {
100+
final SKErrorMessage msg = SKErrorMessage(code: 99, domain: 'domain');
101+
final SKError wrapper = SKError.convertFromPigeon(msg);
102+
103+
expect(wrapper.code, 99);
104+
expect(wrapper.domain, 'domain');
105+
expect(wrapper.userInfo, <String, Object>{});
106+
});
98107
}

0 commit comments

Comments
 (0)