postRequest static method
Implementation
static Future<Response> postRequest(
{required String endpoint,
required Map<String, dynamic> body,
String? key,
bool customUrl = false}) async {
late var headerWithToken;
if (key != null) {
headerWithToken = {
"Content-Type": "application/json",
"x-growlytics-key": "$key",
"glytics_env": "production",
"Accept": "application/json"
};
}
Uri uri = (customUrl)
? Uri.parse(endpoint)
: Uri.parse(Endpoints.baseUrl2 + endpoint);
Response response = await post(uri,
body: jsonEncode(body),
headers: (key != null) ? headerWithToken : _header)
.timeout(
Duration(
seconds: 30,
), onTimeout: () {
return Response("Time Out", 408);
});
return response;
}