This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
packages/in_app_purchase/in_app_purchase/example/lib Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -258,7 +258,9 @@ class _MyAppState extends State<_MyApp> {
258
258
productDetails.description,
259
259
),
260
260
trailing: previousPurchase != null
261
- ? Icon (Icons .check)
261
+ ? IconButton (
262
+ onPressed: () => confirmPriceChange (context),
263
+ icon: Icon (Icons .upgrade))
262
264
: TextButton (
263
265
child: Text (productDetails.price),
264
266
style: TextButton .styleFrom (
@@ -451,7 +453,7 @@ class _MyAppState extends State<_MyApp> {
451
453
});
452
454
}
453
455
454
- Future <void > confirmPriceChange () async {
456
+ Future <void > confirmPriceChange (BuildContext context ) async {
455
457
if (Platform .isAndroid) {
456
458
final InAppPurchaseAndroidPlatformAddition androidAddition =
457
459
_inAppPurchase
@@ -461,9 +463,16 @@ class _MyAppState extends State<_MyApp> {
461
463
sku: 'purchaseId' ,
462
464
);
463
465
if (priceChangeConfirmationResult.responseCode == BillingResponse .ok) {
464
- // TODO acknowledge price change
466
+ ScaffoldMessenger .of (context).showSnackBar (SnackBar (
467
+ content: Text ('Price change accepted' ),
468
+ ));
465
469
} else {
466
- // TODO show error
470
+ ScaffoldMessenger .of (context).showSnackBar (SnackBar (
471
+ content: Text (
472
+ priceChangeConfirmationResult.debugMessage ??
473
+ "Price change failed with code ${priceChangeConfirmationResult .responseCode }" ,
474
+ ),
475
+ ));
467
476
}
468
477
}
469
478
if (Platform .isIOS) {
You can’t perform that action at this time.
0 commit comments