initBuyNow method
void
initBuyNow({
- required BuildContext context,
- required PlayState playState,
- required Datum content,
- required Function onLoadCallback,
- bool isContinueWatchingItemClicked = false,
Implementation
void initBuyNow(
{required BuildContext context,
required PlayState playState,
required Datum content,
required Function onLoadCallback,
bool isContinueWatchingItemClicked = false}) async {
onLoadCallback(PlayState(
buttonState: playState.buttonState,
isLoading: true,
));
String url = "";
if (kIsWeb) {
url = await _generateCheckoutUrl(content, context);
}
SharedPreferences sharedPreferences = await DeviceStorage().getInstance();
sharedPreferences.setString(DeviceStorage.purchaseListData, "");
if (context.mounted) {
if (kIsWeb) {
_launchUrl(url, context);
onLoadCallback(PlayState(
buttonState: playState.buttonState,
buttonText: PlayButtonState.buy,
isLoading: false));
} else {
//Call to show bottom sheet dialog for purchase
// await initInAppPayment(content, onLoadCallback, context);
}
}
}