updatePost method
Implementation
Future<Post> updatePost(int id, Post post) async {
final response = await http.put(
Uri.parse("$url/$id"),
body: jsonEncode(post.toJson()),
);
if (response.statusCode == 200) {
return Post.fromJson(jsonDecode(response.body));
} else {
throw Exception("Failed to update post");
}
}