Skip to content

[webview] Allow overriding responses to webview requests with local resources #27896

@amirh

Description

@amirh

customer: dream are managing their own resource cache.
They need to be able to have the webview respond to specific requests with resources that are available locally and are provided by the application.

On Android this can be done with WebViewClient#shouldInterceptRequest, one challenge there is that shouldInterceptRequest needs to synchronously return a WebResourceResponse, so the decision of whether to intercept the request, and what is the mime type encoding(and potentially some other metadata) has to be synchronous. The documentation does mention that the "method is called on a thread other than the UI thread", need to check if it's ok to block that thread briefly.

On iOS as far as I can tell there isn't a mechanism for doing this per-webview, though it is possible to override URL loading for the entire app by registering a custom NSURLProtocol implementation.

It looks like we might end up with different APIs for Android and iOS, where the iOS API isn't part of the webview (I'm not even sure if it belongs in the webview plugin)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilitycustomer: dream (g3)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