Any packages that allows creating a webview with capability of modifying request and response

Hello,
Are there any packages that provides a webview, which can intercept and modify:
1- request sent by the client before it is sent to the server
2- response sent by the server before reaching the client

Regards

Maybe use Dio interceptors for that?

1 Like

Something like Dio interceptors with a WebView would be awesome, Afaik Dio doesn’t provide a webview

can you describe what you need to do?

Does the “official” webview package not do this? It can definitely intercept responses sent by the server but maybe not to the level of granularity you’re looking for?

1 Like

I want to modify add a cookie to the request before it is sent, and preferably modify the response before it reaches the client(to remove some html elements that might include sensitive info)

Do you have an example?

I’ve used the https://pub.dev/packages/flutter_inappwebview package to intercept and modify requests.

It is a very customizable package for this use case.

3 Likes

Hello I made a linkedIn post about that a week a go,

Using this package you get a WebView controller that tracks your redirections, JavaScript events, and exposes multiple callbacks you get to use to listen and control your embedded webview’s behavior,
I have used it to create a custom payment gateway plug-in that does not have a flutter package yet.
I’ll post the link to the post, you can read the article and contact me if you need any further details.
To answer your question specifically, the controller has an " OnRequest" property if I recall it right, which you could use to either choose to forward the request or reject it.
Link to my profile, you LL find the post featured.

https://www.linkedin.com/in/koussay-issaoui-b67211199?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=android_app

It’s quite simple to get an HTTP server on your Flutter app.

Just use it to create a man-in-the-middle attack. Obviously, all certificates will be void.