Question
Flutter Sample app "Purchase_tester" throwing error
+2
I am testing out the sample app “Purchase_tester” and getting an error in the following part of the code highlight in orange.
class _PurchaseButton extends StatelessWidget {
final Package package;
const _PurchaseButton({Key? key, required this.package}) : super(key: key);
@override
Widget build(BuildContext context) => ElevatedButton(
onPressed: () async {
try {
final purchaserInfo = await Purchases.purchasePackage(package);
} on PlatformException catch (e) {
final errorCode = PurchasesErrorHelper.getErrorCode(e);
if (errorCode == PurchasesErrorCode.purchaseCancelledError) {
print('User cancelled');
} else if (errorCode ==
PurchasesErrorCode.purchaseNotAllowedError) {
print('User not allow to purchase');
} else if (errorCode == PurchasesErrorCode.paymentPendingError) {
print('Payment is pending');
}
}
return const InitialScreen();
},
child: Text('Buy - (${package.product.priceString})'),
);
}
The error says; The return type 'InitialScreen' isn't a 'Future<void>', as required by the closure's context.
Any help would be very much appreciated
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.