Simple HTTP Connection

Simple HTTP Connection, a library that i made to help me request data from internet while i develop flutter app, so i think i wanted to share it here ☺ This library using Http, Made with love by Moch. Nizwar Syafuan

Let's Code!

var url = ""
ResponseHttp respHttp = await  HttpConnection.doConnection(url);
print("Status Code : ${respHttp.statusCode}");
print("Status Headers : ${respHttp.headers}");
print("Content : ${respHttp.content}");

You can convert it to JSON easily, just put asJson() after content and you are ready to go :)

//it will return null if content isn't valid to convert to json
print("Content : ${respHttp.content.asJson()}");

Now, you can also making multiple requests to the same server, just keep open a presisten connection like this

ResponseHttp respHttp = await httpConnection.connect(tryUrl, method:; 
httpConnection.close(); //Close, if you do not want to use it
httpConnection.initConnection();   ///You have to init the connection if you want to use it again
respHttp = await httpConnection.connect(tryUrl, method:; 

Request Stuff


Psst....i made GET request look fun!

///Get Request
Map<String, String> params = Map();
params["foo1"] = "bar1";
params["foo2"] = "bar2";
ResponseHttp respHttp =await  HttpConnection.doConnection(url, method: Method.get, body: params);


HttpConnection.doConnection(url, method:, body: params);


HttpConnection.doConnection(url, method: HttpConnection.put, body: params);


HttpConnection.doConnection(url, method: HttpConnection.patch, body: params);


HttpConnection.doConnection(url, method: HttpConnection.delete);


Default encoding is UTF8, you can change it of course

HttpConnection.doConnection(url, encoding: utf8);


Now you can download file from SimpleDownload in simpliest way :D Thanks to Eka Setiawan Saputra from Flutter Indonesia for inspiring me... Updated, now you can controll your download progress....

SimpleDownload simpleDownload = SimpleDownload();
print(await simpleDownload.start(
    path: "D:", downloadProgress: (progress, count, max) {
    print("Downloading : " + progress.toString() + "%");
simpleDownload.pause();  //Pause your download
simpleDownload.resume(); //Resume your download 
simpleDownload.stop();   //Stop your download


Coded by Happy man who love chocolates Moch Nizwar Syafuan, [...]