Created
January 3, 2022 07:28
-
-
Save coderspacedev/0f8e1f41b485480599e9c0c5c3446595 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void initListeners() { | |
billingHelper?.setPurchaseUpdateHandler((status, value) async { | |
switch (status) { | |
case 'success': | |
if (kDebugMode) { | |
print('$status : $value'); | |
ScaffoldMessenger.of(context).showSnackBar(SnackBar( | |
duration: const Duration(seconds: 1), | |
backgroundColor: Utils.getPrimaryColor(), | |
content: Text( | |
'Purchase Sucessfully', | |
style: TextStyle(fontSize: 18.0, fontFamily: 'Sans', fontStyle: FontStyle.normal, fontWeight: FontWeight.w500, color: Utils.getWhiteColor()), | |
))); | |
} | |
break; | |
case 'cancelled': | |
if (kDebugMode) { | |
print('$status : $value'); | |
ScaffoldMessenger.of(context).showSnackBar(SnackBar( | |
duration: const Duration(seconds: 1), | |
backgroundColor: Utils.getPrimaryColor(), | |
content: Text( | |
'Purchase cancelled by you', | |
style: TextStyle(fontSize: 18.0, fontFamily: 'Sans', fontStyle: FontStyle.normal, fontWeight: FontWeight.w500, color: Utils.getWhiteColor()), | |
))); | |
} | |
break; | |
case 'error': | |
if (kDebugMode) { | |
print('$status : $value'); | |
ScaffoldMessenger.of(context).showSnackBar(SnackBar( | |
duration: const Duration(seconds: 1), | |
backgroundColor: Utils.getPrimaryColor(), | |
content: Text( | |
'Something went wrong, Please try again after sometime', | |
style: TextStyle(fontSize: 18.0, fontFamily: 'Sans', fontStyle: FontStyle.normal, fontWeight: FontWeight.w500, color: Utils.getWhiteColor()), | |
))); | |
} | |
break; | |
case 'restore': | |
if (kDebugMode) { | |
print('$status : $value'); | |
ScaffoldMessenger.of(context).showSnackBar(SnackBar( | |
duration: const Duration(seconds: 1), | |
backgroundColor: Utils.getPrimaryColor(), | |
content: Text( | |
value ? 'Restore Successfully' : 'You don\'t have purchase to restore', | |
style: TextStyle(fontSize: 18.0, fontFamily: 'Sans', fontStyle: FontStyle.normal, fontWeight: FontWeight.w500, color: Utils.getWhiteColor()), | |
))); | |
} | |
break; | |
default: | |
if (kDebugMode) { | |
print('$status : $value'); | |
} | |
} | |
}); | |
billingHelper!.setPriceUpdateHandler((price) { | |
if (kDebugMode) { | |
print("Price: $price"); | |
setState(() { | |
this.price = price; | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment