chanomhub_flutter 1.0.1
chanomhub_flutter: ^1.0.1 copied to clipboard
Official Flutter SDK for Chanomhub API. Access articles, authentication, downloads, and automated image processing with imgproxy support.
example/main.dart
import 'package:chanomhub_flutter/chanomhub_flutter.dart';
void main() async {
// 1. Initialize the SDK
final sdk = ChanomhubClient(
baseUrl: 'https://api.chanomhub.com',
cdnUrl: 'https://imgproxy.chanomhub.com',
);
print('๐งช Chanomhub SDK Test Drive ๐งช');
try {
// 2. Fetch Latest Articles
print('\n[Fetching Articles...]');
final response = await sdk.articles.getAllPaginated(
options: ArticleListOptions(limit: 3),
);
print('โ
Found ${response.total} articles total.');
for (var article in response.items) {
print(' ๐ ${article.title}');
print(' ๐ผ๏ธ Image: ${article.mainImage}'); // Auto-transformed URL
}
// 3. Search for a specific query
print('\n[Searching for "visual novel" with Thai tag...]');
final searchResult = await sdk.search.articles(
'visual novel',
options: SearchOptions(tag: 'Thai', limit: 2),
);
print('โ
Search found ${searchResult.items.length} results.');
// 4. Test Error Handling (Invalid Login)
print('\n[Testing Error Handling (Invalid Login)...]');
try {
await sdk.auth.login(
email: 'invalid@example.com',
password: 'wrong_password',
);
} on AuthenticationException catch (e) {
print('โ
Caught expected exception: ${e.message} (Status: ${e.statusCode})');
}
} catch (e) {
print('โ Unexpected error: $e');
} finally {
sdk.dispose();
}
}