loadPosts method
Implementation
Future<void> loadPosts() async {
if (community.value == null) return;
isLoading.value = true;
try {
final token = Hive.box('user_data').get('user_token');
final response = await _dioApiService.get(
endpoint: CommunityConstants.posts,
headers: {
'api-key': CommunityConstants.apiKey,
if (token != null) 'Authorization': 'Bearer $token',
},
query: {'community_id': community.value!.id.toString()},
);
if (response.statusCode == 200) {
postsResponse.value = PostsResponse.fromJson(response.data);
}
} finally {
isLoading.value = false;
}
}