Extending BaseRequest to make custom post request

Issue

I am trying to make custom post request with BrowserClient (package:http/browser_client.dart) using send method. I don`t understand how should i extend abstract BaseRequest, should i override finalize method?

Solution

Unless you’re doing something very custom, you want to use one of the subclasses of the abstract BaseRequest class (seen in the docs under Implemented by).

I’m almost sure you want to just use the Request class, like so:

var client = new BrowserClient();
var request = new Request("post", Uri.parse("http://example.com"));
// ... set up the request some more ...
var response = await client.send(request);
// ... do stuff with response ...

Answered By – filiph

Answer Checked By – Katrina (FlutterFixes Volunteer)

Leave a Reply

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