getText method

String getText(
  1. Map<String, dynamic> textJson
)

Implementation

String getText(Map<String, dynamic> textJson) {
  String text = textJson[RCConstants.keyText] ?? "";
  if (text.contains(RCConstants.keyInAppPrice)) {
    String productId = textJson[RCConstants.keyProductId] ?? "";
    if (productId.isEmpty) {
      Exception("ProductId is required to show price.");
      return RCConstants.invalidValue;
    }
    int? dividePriceBy = textJson[RCConstants.keyDividePriceBy];
    InAppPurchaseService pInstance = InAppPurchaseService.instance;
    String pPrice = pInstance.getProductPrice(productId, dividePriceBy);
    if (onFetchProduct != null) onFetchProduct!(productId);
    return text.replaceAll(RCConstants.keyInAppPrice, pPrice);
  }
  return text;
}