chanomhub_flutter 1.0.2 copy "chanomhub_flutter: ^1.0.2" to clipboard
chanomhub_flutter: ^1.0.2 copied to clipboard

Official Flutter SDK for Chanomhub API. Access articles, authentication, downloads, and automated image processing with imgproxy support.

Chanomhub Flutter SDK #

pub package License: MIT Build Status

A professional, feature-rich Flutter SDK for the Chanomhub API. This package provides a seamless way to interact with Chanomhub's backend, supporting both GraphQL and REST operations with automated image processing.


๐ŸŒŸ Features #

  • โšก GraphQL v2 Integration: High-performance data fetching with custom field selection (Presets).
  • ๐Ÿ–ผ๏ธ Auto Image Transform: Automated imgproxy URL generation for all image fields.
  • ๐Ÿ” Full Auth Support: Login, Registration, Token Refresh, and Session Management.
  • ๐Ÿ“ฆ Complete Modules:
    • Articles: Search, Filter, and Paginated article lists.
    • Users: Profile management, Follow/Unfollow system.
    • Downloads: Manage download links with VIP & Versioning support.
    • Subscriptions: Access plans and user subscription status.
    • Mods & Sponsored: Specialized modules for community content and promotions.
  • ๐Ÿ› ๏ธ Robust Error Handling: Domain-specific exceptions for easy debugging.

๐Ÿš€ Installation #

Add this to your pubspec.yaml:

dependencies:
  chanomhub_flutter: ^1.0.0

Then run:

flutter pub get

๐Ÿšฆ Quick Start #

Initialize the Client #

import 'package:chanomhub_flutter/chanomhub_flutter.dart';

final sdk = ChanomhubClient(
  baseUrl: 'https://api.chanomhub.com',
  cdnUrl: 'https://imgproxy.chanomhub.com', // Required for image processing
  token: 'YOUR_AUTH_TOKEN', // Optional: for authenticated requests
);

Fetch Articles (GraphQL) #

// Fetch paginated articles with 'standard' field preset
final response = await sdk.articles.getAllPaginated(
  options: ArticleListOptions(limit: 10, offset: 0),
);

for (var article in response.items) {
  print(article.title);
  print(article.mainImage); // Automatically transformed to imgproxy URL!
}

Search Articles #

final searchResult = await sdk.search.articles(
  'visual novel',
  options: SearchOptions(tag: 'Thai'),
);

๐ŸŽจ Image Processing (Imgproxy) #

All image fields returned by the SDK are automatically transformed based on the cdnUrl provided. You can also manually transform URLs using the resolveImageUrl utility:

final customUrl = resolveImageUrl(
  article.mainImage,
  sdk.cdnUrl,
  options: ImgproxyOptions(
    width: 300,
    height: 200,
    resizeType: 'fill',
    format: 'webp',
  ),
);

๐Ÿงฉ Advanced Usage #

Authentication Flow #

try {
  final response = await sdk.auth.login(
    email: 'user@example.com',
    password: 'secure_password',
  );
  print('Welcome, ${response.user.username}!');
  
  // Re-initialize or update headers with the new token
  sdk.dio.options.headers['Authorization'] = 'Bearer ${response.user.token}';
} on UnauthorizedException {
  print('Invalid credentials!');
} on ChanomhubException catch (e) {
  print('API Error: ${e.message}');
}

๐Ÿงช Testing #

The SDK comes with a built-in mock testing suite. To run the tests:

flutter test

๐Ÿ“„ License #

This SDK is released under the MIT License. See LICENSE for details.


๐Ÿค Contributing #

Contributions are welcome! Please feel free to submit a Pull Request or open an Issue on GitHub.

0
likes
125
points
230
downloads

Documentation

API reference

Publisher

verified publisherchanomhub.com

Weekly Downloads

Official Flutter SDK for Chanomhub API. Access articles, authentication, downloads, and automated image processing with imgproxy support.

Repository (GitHub)
View/report issues

Topics

#sdk #graphql #rest #api-client #image-processing

License

MIT (license)

Dependencies

dio, flutter, json_annotation

More

Packages that depend on chanomhub_flutter