Skip to content

Commit

Permalink
Merge pull request #24 from koji-1009/chore/doc
Browse files Browse the repository at this point in the history
chore: Add doc
  • Loading branch information
koji-1009 authored Jan 5, 2024
2 parents 7dfb33d + 5507c26 commit 5df25eb
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/src/network/http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:taro/src/taro_loader_network.dart';

/// [HttpClient] is a class that manages the sending of GET requests to the provided URL.
class HttpClient implements TaroHttpClient {
/// Creates a [HttpClient].
const HttpClient({
this.timeout = const Duration(
seconds: 180,
Expand Down
1 change: 1 addition & 0 deletions lib/src/taro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:taro/src/taro_type.dart';

/// [Taro] is a library for loading images. It uses two loaders: Storage and Network.
class Taro {
/// Creates a [Taro].
Taro._();

/// Creates a new instance of the [Taro] class.
Expand Down
10 changes: 10 additions & 0 deletions lib/src/taro_exception.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/// [TaroException] is a base class for all exceptions in the Taro.
sealed class TaroException implements Exception {
/// Creates a [TaroException].
const TaroException();
}

/// [TaroLoadException] is thrown when there is an issue with loading data in the Taro library.
final class TaroLoadException extends TaroException {
/// Creates a [TaroLoadException].
const TaroLoadException({
required this.message,
});
Expand All @@ -19,6 +21,7 @@ final class TaroLoadException extends TaroException {
/// [TaroStorageException] is thrown when there is an issue with storage operations in the Taro library.
/// It includes the original exception that caused the error.
final class TaroStorageException extends TaroException {
/// Creates a [TaroStorageException].
const TaroStorageException({
required this.exception,
});
Expand All @@ -33,6 +36,7 @@ final class TaroStorageException extends TaroException {
/// [TaroUriParseException] is thrown when there is an issue with parsing a URI in the Taro library.
/// It includes the URL that was being parsed.
final class TaroUriParseException extends TaroException {
/// Creates a [TaroUriParseException].
const TaroUriParseException({
required this.url,
});
Expand All @@ -47,6 +51,7 @@ final class TaroUriParseException extends TaroException {
/// [TaroNetworkException] is thrown when there is an issue with network operations in the Taro library.
/// It includes the URL that was being accessed and the original error that caused the issue.
final class TaroNetworkException extends TaroException {
/// Creates a [TaroNetworkException].
const TaroNetworkException({
required this.url,
required this.error,
Expand All @@ -66,6 +71,7 @@ final class TaroNetworkException extends TaroException {
/// It includes the status code, reason phrase, content length, headers, and whether the response is a redirect.
/// This exception is thrown when the status code is not in the range 200-399.
final class TaroHttpResponseException extends TaroException {
/// Creates a [TaroHttpResponseException].
const TaroHttpResponseException({
required this.statusCode,
required this.reasonPhrase,
Expand Down Expand Up @@ -98,6 +104,7 @@ final class TaroHttpResponseException extends TaroException {
/// It includes the URL that was being accessed.
/// This exception is thrown when the response body is empty.
final class TaroEmptyResponseException extends TaroException {
/// Creates a [TaroEmptyResponseException].
const TaroEmptyResponseException({
required this.url,
});
Expand All @@ -113,6 +120,7 @@ final class TaroEmptyResponseException extends TaroException {
/// It includes the cache-control header and the original exception that caused the error.
/// This exception is thrown when the status code is in the range 200-399.
final class TaroCacheControlException extends TaroException {
/// Creates a [TaroCacheControlException].
const TaroCacheControlException({
required this.cacheControl,
required this.error,
Expand All @@ -132,6 +140,7 @@ final class TaroCacheControlException extends TaroException {
/// [TaroResizeException] is thrown when there is an issue with resizing an image in the Taro library.
/// It includes the original exception that caused the error.
final class TaroResizeException extends TaroException {
/// Creates a [TaroResizeException].
const TaroResizeException({
required this.exception,
});
Expand All @@ -145,6 +154,7 @@ final class TaroResizeException extends TaroException {

/// [TaroResizeFailedException] is thrown when there is an issue with resizing an image in the Taro library.
final class TaroResizeFailedException extends TaroException {
/// Creates a [TaroResizeFailedException].
const TaroResizeFailedException();

@override
Expand Down
1 change: 1 addition & 0 deletions lib/src/taro_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:taro/src/taro_type.dart';
/// [TaroImage] is an [ImageProvider] that loads images from the network and caches them.
@immutable
class TaroImage extends ImageProvider<TaroImage> {
/// Creates a [TaroImage].
const TaroImage(
this.url, {
this.scale = 1.0,
Expand Down
1 change: 1 addition & 0 deletions lib/src/taro_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:taro/src/taro_type.dart';

/// [TaroLoader] is a class that manages different types of loaders.
class TaroLoader {
/// Creates a [TaroLoader].
TaroLoader();

/// The [TaroLoaderNetwork] instance used to load data from the network.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/taro_loader_network.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ typedef TaroHttpResponse = ({

/// [TaroHttpClient] is an interface class for GET requests to the specified URL.
abstract interface class TaroHttpClient {
/// Creates a [TaroHttpClient].
const TaroHttpClient();

Future<TaroHttpResponse> get({
Expand All @@ -30,6 +31,7 @@ abstract interface class TaroHttpClient {
/// [TaroLoaderNetwork] is a class that manages the loading of data from a network source.
/// It uses the http package to send GET requests to the provided URL.
class TaroLoaderNetwork {
/// Creates a [TaroLoaderNetwork].
const TaroLoaderNetwork({
this.resizer = const TaroResizer(),
this.client = const HttpClient(),
Expand Down
1 change: 1 addition & 0 deletions lib/src/taro_loader_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:taro/src/taro_type.dart';

/// The [TaroLoaderStorage] class is used to load and save data from storage.
class TaroLoaderStorage {
/// Creates a [TaroLoaderStorage].
const TaroLoaderStorage();

/// Loads the data from the provided URL from storage.
Expand Down
1 change: 1 addition & 0 deletions lib/src/taro_resizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:taro/src/taro_type.dart';

/// The [TaroResizer] class is used to resize images.
class TaroResizer {
/// Creates a [TaroResizer].
const TaroResizer();

/// Resize the image if needed.
Expand Down
1 change: 1 addition & 0 deletions lib/src/taro_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ typedef TaroPlaceholderBuilder = Widget Function(
/// [TaroWidget] is a widget for loading images. It uses two loaders: Storage and Network.
/// Images that have been loaded once are cached in [ImageCache].
class TaroWidget extends StatelessWidget {
/// Creates a widget that displays an image from a [TaroImageProvider].
const TaroWidget({
super.key,
required this.url,
Expand Down

0 comments on commit 5df25eb

Please sign in to comment.