Skip to content

Commit f79ef2c

Browse files
committed
Fix RequiresFeature lint: setPaymentRequestEnabled should only be called if the feature PAYMENT_REQUEST is present
Ensures the function works correctly even when called without prior WebViewFeature.isFeatureSupported check. ref. https://developers.google.com/pay/api/android/guides/recipes/using-android-webview#enable-payment-request-api
1 parent 103e29f commit f79ef2c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebSettingsCompatProxyApi.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.webkit.WebSettings;
88
import androidx.annotation.NonNull;
99
import androidx.webkit.WebSettingsCompat;
10+
import androidx.webkit.WebViewFeature;
1011

1112
/**
1213
* Host api implementation for {@link WebSettingsCompat}.
@@ -20,6 +21,8 @@ public WebSettingsCompatProxyApi(@NonNull ProxyApiRegistrar pigeonRegistrar) {
2021

2122
@Override
2223
public void setPaymentRequestEnabled(@NonNull WebSettings webSettings, boolean enabled) {
23-
WebSettingsCompat.setPaymentRequestEnabled(webSettings, enabled);
24+
if (WebViewFeature.isFeatureSupported(WebViewFeature.PAYMENT_REQUEST)) {
25+
WebSettingsCompat.setPaymentRequestEnabled(webSettings, enabled);
26+
}
2427
}
2528
}

0 commit comments

Comments
 (0)