-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[in_app_purchase] Migrate to NNBD #3555
Changes from all commits
1e03d43
5eac602
cb2b07a
8241118
65e359c
3d015a1
af8fb62
0b5a7d9
51de2a1
de99f9a
05ea190
241d3b9
fa360e7
10473e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ targets: | |
options: | ||
any_map: true | ||
create_to_json: true | ||
nullable: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is deprecated, so removing |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,19 +32,19 @@ class _MyApp extends StatefulWidget { | |
|
||
class _MyAppState extends State<_MyApp> { | ||
final InAppPurchaseConnection _connection = InAppPurchaseConnection.instance; | ||
StreamSubscription<List<PurchaseDetails>> _subscription; | ||
late StreamSubscription<List<PurchaseDetails>> _subscription; | ||
List<String> _notFoundIds = []; | ||
List<ProductDetails> _products = []; | ||
List<PurchaseDetails> _purchases = []; | ||
List<String> _consumables = []; | ||
bool _isAvailable = false; | ||
bool _purchasePending = false; | ||
bool _loading = true; | ||
String _queryProductError; | ||
String? _queryProductError; | ||
|
||
@override | ||
void initState() { | ||
Stream purchaseUpdated = | ||
final Stream<List<PurchaseDetails>> purchaseUpdated = | ||
InAppPurchaseConnection.instance.purchaseUpdatedStream; | ||
_subscription = purchaseUpdated.listen((purchaseDetailsList) { | ||
_listenToPurchaseUpdated(purchaseDetailsList); | ||
|
@@ -76,7 +76,7 @@ class _MyAppState extends State<_MyApp> { | |
await _connection.queryProductDetails(_kProductIds.toSet()); | ||
if (productDetailResponse.error != null) { | ||
setState(() { | ||
_queryProductError = productDetailResponse.error.message; | ||
_queryProductError = productDetailResponse.error!.message; | ||
_isAvailable = isAvailable; | ||
_products = productDetailResponse.productDetails; | ||
_purchases = []; | ||
|
@@ -146,7 +146,7 @@ class _MyAppState extends State<_MyApp> { | |
); | ||
} else { | ||
stack.add(Center( | ||
child: Text(_queryProductError), | ||
child: Text(_queryProductError!), | ||
)); | ||
} | ||
if (_purchasePending) { | ||
|
@@ -235,7 +235,7 @@ class _MyAppState extends State<_MyApp> { | |
})); | ||
productList.addAll(_products.map( | ||
(ProductDetails productDetails) { | ||
PurchaseDetails previousPurchase = purchases[productDetails.id]; | ||
PurchaseDetails? previousPurchase = purchases[productDetails.id]; | ||
return ListTile( | ||
title: Text( | ||
productDetails.title, | ||
|
@@ -254,8 +254,7 @@ class _MyAppState extends State<_MyApp> { | |
onPressed: () { | ||
PurchaseParam purchaseParam = PurchaseParam( | ||
productDetails: productDetails, | ||
applicationUserName: null, | ||
sandboxTesting: true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this use the new replacement instead of just removing the argument? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The general testing flow actually doesn't need to include |
||
applicationUserName: null); | ||
if (productDetails.id == _kConsumableId) { | ||
_connection.buyConsumable( | ||
purchaseParam: purchaseParam, | ||
|
@@ -329,7 +328,7 @@ class _MyAppState extends State<_MyApp> { | |
void deliverProduct(PurchaseDetails purchaseDetails) async { | ||
// IMPORTANT!! Always verify a purchase purchase details before delivering the product. | ||
if (purchaseDetails.productID == _kConsumableId) { | ||
await ConsumableStore.save(purchaseDetails.purchaseID); | ||
await ConsumableStore.save(purchaseDetails.purchaseID!); | ||
List<String> consumables = await ConsumableStore.load(); | ||
setState(() { | ||
_purchasePending = false; | ||
|
@@ -365,7 +364,7 @@ class _MyAppState extends State<_MyApp> { | |
showPendingUI(); | ||
} else { | ||
if (purchaseDetails.status == PurchaseStatus.error) { | ||
handleError(purchaseDetails.error); | ||
handleError(purchaseDetails.error!); | ||
} else if (purchaseDetails.status == PurchaseStatus.purchased) { | ||
bool valid = await _verifyPurchase(purchaseDetails); | ||
if (valid) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,9 @@ author: Flutter Team <[email protected]> | |
dependencies: | ||
flutter: | ||
sdk: flutter | ||
cupertino_icons: ^0.1.2 | ||
shared_preferences: ^0.5.2 | ||
shared_preferences: ^2.0.0-nullsafety.1 | ||
|
||
dev_dependencies: | ||
test: ^1.5.2 | ||
flutter_driver: | ||
sdk: flutter | ||
in_app_purchase: | ||
|
@@ -21,11 +19,11 @@ dev_dependencies: | |
path: ../ | ||
integration_test: | ||
path: ../../integration_test | ||
pedantic: ^1.8.0 | ||
pedantic: ^1.10.0 | ||
|
||
flutter: | ||
uses-material-design: true | ||
|
||
environment: | ||
sdk: ">=2.3.0 <3.0.0" | ||
sdk: ">=2.12.0-259.9.beta <3.0.0" | ||
flutter: ">=1.9.1+hotfix.2" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ - (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar | |
}]; | ||
[_paymentQueueHandler startObservingPaymentQueue]; | ||
_callbackChannel = | ||
[FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/in_app_purchase_callback" | ||
[FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/in_app_purchase" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for flutter/flutter#69225 |
||
binaryMessenger:[registrar messenger]]; | ||
return self; | ||
} | ||
|
@@ -290,7 +290,7 @@ - (void)refreshReceipt:(FlutterMethodCall *)call result:(FlutterResult)result { | |
}]; | ||
} | ||
|
||
#pragma mark - delegates | ||
#pragma mark - delegates: | ||
|
||
- (void)handleTransactionsUpdated:(NSArray<SKPaymentTransaction *> *)transactions { | ||
NSMutableArray *maps = [NSMutableArray new]; | ||
|
Uh oh!
There was an error while loading. Please reload this page.