handleWebViewUrl static method

Future<bool> handleWebViewUrl(
  1. String url
)

Handles a URL from a WebView. Returns true if the URL was handled by Repro (starts with 'repro://'). This method should be called from your WebView's URL handling callback.

Implementation

static Future<bool> handleWebViewUrl(String url) async {
  // flutter_inappwebview ではドメインが全て小文字になるためここで変換する
  Map<String, String> replacements = {
    "repro://setuserprofile": "repro://setUserProfile",
    "repro://trackviewcontent": "repro://trackViewContent",
    "repro://tracksearch": "repro://trackSearch",
    "repro://trackaddtocart": "repro://trackAddToCart",
    "repro://trackaddtowishlist": "repro://trackAddToWishlist",
    "repro://trackinitiatecheckout": "repro://trackInitiateCheckout",
    "repro://trackaddpaymentinfo": "repro://trackAddPaymentInfo",
    "repro://trackpurchase": "repro://trackPurchase",
    "repro://trackshare": "repro://trackShare",
    "repro://tracklead": "repro://trackLead",
    "repro://trackcompleteregistration": "repro://trackCompleteRegistration",
  };
  replacements.forEach((key, value) {
    url = url.replaceFirst(key, value);
  });

  await _invokeMethod('handleWebViewUrl', url);
  return url.startsWith('repro://');
}