asnetworkmanager

A new Flutter package.

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Example

1) Call POST API from async function

//CREATE OBJECT 
NetworkManager _manager = NetworkManager();

//REQUEST URL
String url = "http://*****.*****.com:3000/api/users/login";

//HEADER
Map<String, dynamic> header;
header = {
'Content-Type': 'application/json'
};

//POST BODY
Map<String, dynamic> body;
body = {
"email": "xx@gmail.com",
"password": "12345678"
};

//CALL POST API AND STORE RESPONSE IN response
final response = await _manager.postAPICall(url, body : body, header: header);

2) CALL GET API

//CREATE OBJECT 
NetworkManager _manager = NetworkManager();

//REQUEST URL
String url = "http://*****.*****.com:3000/api/products";

//HEADER
Map<String, dynamic> header;
header = {
'Content-Type': 'application/json'
};

//CALL GET API AND STORE RESPONSE IN response
final response = await _provider.getAPICall(url, header : headers);

3) CALL DELETE API

//CREATE OBJECT OF 
NetworkManager _manager = NetworkManager();

//REQUEST URL
String url = http://*****.*****.com:3000/api/products/29 ;

//HEADER
Map<String, dynamic> header;
header = {
'Content-Type': 'application/json'
};

//CALL DELETE API AND STORE RESPONSE IN response
final response = await _manager.deleteAPICall(url, header : header);

4) CALL PUT API

//CREATE OBJECT OF
NetworkManager _manager = NetworkManager();

//REQUEST URL
String url = http://*****.*****.com:3000/api/products/ ;

//HEADER
Map<String, dynamic> header;
header = {
'Content-Type': 'application/json'
};

//PUT BODY
Map<String, dynamic> body;
body = {
"name": "xxxx",
"type": "xxxx"
};

//CALL PUT API AND STORE RESPONSE IN response
final response = await _manager.putAPICall(url, body: body, header: header);

Libraries

asnetworkmanager