addPost method

Future<Response> addPost({
  1. required UserModel user,
  2. required String? title,
  3. required String? description,
  4. required String? type,
  5. String? attachedUrl,
  6. int? pollQuestionId,
})

Implementation

Future<http.Response> addPost({
  required UserModel user,
  required String? title,
  required String? description,
  required String? type,
  String? attachedUrl,
  int? pollQuestionId,
}) {
  var data = json.encode({
    "user": user.id,
    "description": description,
    "type": type,
    "attachedUrl": attachedUrl,
    "title": title,
    "pollQuestion": pollQuestionId
  });
  log(data);

  return post(Uri.parse('$apiURL/posts/create'),
      headers: {
        "token":
            "cnejwi8c9wehnd8fchni2x239jxexnjx2n23i8xn3oifr0cwd32fjnrf453vreve",
        "content-type": 'application/json',
      },
      body: data);
}