Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 4b62107

Browse files
committed
Added snackbar messages for price change confirmation
1 parent a715a60 commit 4b62107

File tree

1 file changed

+13
-4
lines changed
  • packages/in_app_purchase/in_app_purchase/example/lib

1 file changed

+13
-4
lines changed

packages/in_app_purchase/in_app_purchase/example/lib/main.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ class _MyAppState extends State<_MyApp> {
258258
productDetails.description,
259259
),
260260
trailing: previousPurchase != null
261-
? Icon(Icons.check)
261+
? IconButton(
262+
onPressed: () => confirmPriceChange(context),
263+
icon: Icon(Icons.upgrade))
262264
: TextButton(
263265
child: Text(productDetails.price),
264266
style: TextButton.styleFrom(
@@ -451,7 +453,7 @@ class _MyAppState extends State<_MyApp> {
451453
});
452454
}
453455

454-
Future<void> confirmPriceChange() async {
456+
Future<void> confirmPriceChange(BuildContext context) async {
455457
if (Platform.isAndroid) {
456458
final InAppPurchaseAndroidPlatformAddition androidAddition =
457459
_inAppPurchase
@@ -461,9 +463,16 @@ class _MyAppState extends State<_MyApp> {
461463
sku: 'purchaseId',
462464
);
463465
if (priceChangeConfirmationResult.responseCode == BillingResponse.ok) {
464-
// TODO acknowledge price change
466+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
467+
content: Text('Price change accepted'),
468+
));
465469
} 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+
));
467476
}
468477
}
469478
if (Platform.isIOS) {

0 commit comments

Comments
 (0)