postScreenData method

Future postScreenData(
  1. ScreenPayload payload
)

Implementation

Future<dynamic> postScreenData(ScreenPayload payload) async {
  try {
    final response = await http.post(
      Uri.parse(_url),
      headers: _headers,
      body: jsonEncode(payload),
    );

    if (response.statusCode == 200 || response.statusCode == 201) {
      debugPrint('Payload sent successfully :');
      //return jsonDecode(response.body);
    } else {
      throw Exception('Failed with status code: ${response.statusCode}');
    }
  } catch (e) {
    throw Exception('API call error: $e');
  }
}