我在 Flutter 中創建了一個 Webview 應用程式。但是當在沒有互聯網的情況下打開時,它會在此處顯示此 輸入影像描述
我想在沒有互聯網的情況下打開此應用程式時顯示另一張影像。我怎么做?
uj5u.com熱心網友回復:
您可以使用此包來檢查 Internet 連接是否可用。
bool result = await DataConnectionChecker().hasConnection;
return Scaffold(
body: WebView(
if (result == true) {
initialUrl: "https://google.com/",
onWebViewCreated: (WebViewController webViewController){
_controller.complete(webViewController);
},}
else{
//i am not connected to any network
}
) );
uj5u.com熱心網友回復:
在 flutter 中檢查互聯網僅在您使用 android 或 ios 時可用,就像這樣,因為當您打開您的網路應用程式并出現時,這意味著您有連接,如果沒有,則您沒有連接c 檢查互聯網是沒有意義的
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/375457.html
