import 'dart:async'; import 'dart:convert'; import 'dart:io'; class MainController{ //API Access URL final String url = 'https://xxxxx.com/'; Future CallAPI(String Controler,Map map) async { HttpClient client = new HttpClient(); client.badCertificateCallback = ((X509Certificate cert, String host, int port) => true); HttpClientRequest request = await client.postUrl(Uri.parse(url+Controler)); request.headers.set('content-type', 'application/json'); request.add(utf8.encode(json.encode(map))); HttpClientResponse response = await request.close(); String reply = await response.transform(utf8.decoder).join(); print(reply); return reply; } Future LoginCValidate(String Email,String Password) async { //Post Request Body Map map = { "Email" : Email , "Password" : Password }; //Call API //YourControllerName = Rest of the your Request URL Future Result = CallAPI('YourControllerName',map); print(Result); } }