Skip to content

[webview_flutter] Catch and handle all HTTP errors codes (eg 404) to redirect to a custom error page #39502

Closed
flutter/packages
#6378

Description

@majicomajico

Use case

it is currently impossible to capture and manage HTTP status codes and avoid displaying the default page of the missing internet connection.

Proposal

I suggest to create a new property such as "onPageError" to allow an easy iterception of these status codes

Activity

  1. added this to the milestone on Jan 31, 2020
  2. paulobreim commented on Mar 23, 2020

    @paulobreim

    it is very important

  3. added
    customer: crowdAffects or could affect many people, though not necessarily a specific customer.
    on Mar 23, 2020
  4. added
    P2Important issues not at the top of the work list
    on May 29, 2020
  5. removed this from the milestone on Aug 17, 2020
  6. sbd2015 commented on Sep 14, 2021

    @sbd2015

    Do we have any updates on this?

  7. pushparajbhatta commented on Dec 24, 2021

    @pushparajbhatta

    Is there any update on this ?

  8. Stitch-Taotao commented on Jan 20, 2022

    @Stitch-Taotao
    Contributor

    This is very very important feauture!

  9. andreisas06 commented on Jun 7, 2023

    @andreisas06

    Hey @majicomajico,

    Based on your proposal for an onPageError property, it seems you're looking for a way to intercept HTTP status error codes. Considering the functionality of onWebResourceError, it appears that this property might already serve the purpose you're intending with onPageError.

    The onWebResourceError property in the webview_flutter plugin provides a mechanism to handle web resource loading errors. When a web resource fails to load, it triggers this event with a WebResourceError object. This object includes details about the error, such as its description, raw code, and type, which can be used to understand and handle the error effectively. It also indicates whether the error originated from the main frame. It is particularly useful when you want to handle and recover from specific types of web resource errors, or when you need to communicate loading issues to the users.

    Could you confirm if this meets your requirements? If not, could you please provide more details about the specific functionality you're seeking with onPageError?

  10. dinbtechit commented on Nov 20, 2023

    @dinbtechit

    This is a much need feature!!!!!

  11. ClubAce commented on Dec 8, 2023

    @ClubAce

    The onWebResourceError property in the webview_flutter plugin does not catch 404 errors. Thus it seems that the need for an onPageError property is very relevant. Please consider implement the suggested feature in the near future, to the benefit of all that have chosen to utilize this otherwise fine plugin.

  12. bakatsuyuki commented on Dec 18, 2023

    @bakatsuyuki

    I have one solution to this problem.
    We could use http.get to check the status code like this:

    import 'package:http/http.dart' as http;
    // ...
    onWebResourceError: (WebResourceError error) async {
      final response = await http.get(Uri.parse('https://something.com'));
      print(response.statusCode);
    }

    Of course, I also want to use a new property like onPageError, but currently, we could solve it with this solution.

  13. github-actions commented on Jun 7, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilitycustomer: crowdAffects or could affect many people, though not necessarily a specific customer.p: webviewThe WebView pluginpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions