小编ati*_*ikh的帖子

在 flutter webview 中显示自定义错误页面而不是 android 返回的默认错误页面

我正在为我的 webview 应用程序使用flutter_inappwebview插件。有时,由于网络问题,网页无法加载,Android 会在屏幕上抛出错误页面,提示页面未找到或超时错误。

我需要替换android返回的默认错误页面的内容。我能够使用 onLoadError 方法捕获页面未找到错误。

请指导我使用 onLoadError 方法更改默认错误页面。

WillPopScope(
  onWillPop: onWillPop,
  child: InAppWebView(
    initialUrl: 'https://myurl.com',
    onWebViewCreated: (InAppWebViewController controller) {
      webView = controller;
    },
    onLoadError: (InAppWebViewController controller, String url, int i,
        String s) async {
      print('CUSTOM_HANDLER: $i, $s');
      /** instead of printing the console message i want to render a static page or display static message **/
    },
    onLoadHttpError: (InAppWebViewController controller, String url,
        int i, String s) async {
      print('CUSTOM_HANDLER: $i, $s');
      /** instead of printing the …
Run Code Online (Sandbox Code Playgroud)

error-handling webview flutter

1
推荐指数
1
解决办法
6644
查看次数

标签 统计

error-handling ×1

flutter ×1

webview ×1