send data using flutter-inappwebview to web page


I’m using inappwebview package, which opens a web page. I want to receive some data from my Flutter app to my web page (php/html) or there’s may be some better option? Basically the user select a product in the app and then the inappwebview package will open this web page to show some specific products).
I have found that inappwebview postData: "Loads the given [url] with [postData] using POST method into this WebView" and what I have tried is;

    url: "web link",
    postData: utf8.encode(data)

And in web page (php) I don’t know how this data receives, I tried to write it like this;

$data =utf8_decode($_POST['postData']);

Which is not correct i guess. Please help me!


The postData argument represents the Body of the HTTP POST request.

A simple example using the latest version 5.0.5+3 of the flutter_inappwebview plugin is:

var postData = Uint8List.fromList(utf8.encode("firstname=Foo&lastname=Bar"));
controller.postUrl(url: Uri.parse(""), postData: postData);

where the postData is the Body of the request in x-www-form-urlencoded format.

So, in your PHP server, you can access the firstname and lastname values as you normally would do, that is $_POST['firstname'] and $_POST['lastname'].

Answered By – Lorenzo Pichilli

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *