diff --git a/packages/wyatt_architecture/README.md b/packages/wyatt_architecture/README.md
index a40b40c3..263ab0e2 100644
--- a/packages/wyatt_architecture/README.md
+++ b/packages/wyatt_architecture/README.md
@@ -23,7 +23,7 @@
-The Wyatt Architecture for Flutter.
+The Wyatt Architecture for Flutter. Contains useful classes to help you to create a clean architecture following the Wyatt Architecture. (core, data, domain, presentation).
## Features
diff --git a/packages/wyatt_architecture/example/lib/data/repositories/photo_repository_impl.dart b/packages/wyatt_architecture/example/lib/data/repositories/photo_repository_impl.dart
index d7a5aaf3..274502f1 100644
--- a/packages/wyatt_architecture/example/lib/data/repositories/photo_repository_impl.dart
+++ b/packages/wyatt_architecture/example/lib/data/repositories/photo_repository_impl.dart
@@ -36,7 +36,7 @@ class PhotoRepositoryImpl extends PhotoRepository {
@override
FutureOrResult addPhotoToFavorites(Photo photo) => Result.tryCatchAsync(
() => _favoriteLocalDataSource.addPhotoToFavorites(photo),
- (error) => ClientException('Cannot add photo to favorites.'),
+ (error) => const ClientException('Cannot add photo to favorites.'),
);
@override
@@ -63,14 +63,14 @@ class PhotoRepositoryImpl extends PhotoRepository {
FutureOrResult> getAllAlbums({int? start, int? limit}) =>
Result.tryCatchAsync(
() => _albumRemoteDataSource.getAllAlbums(start: start, limit: limit),
- (error) => ServerException('Cannot retrieve all albums.'),
+ (error) => const ServerException('Cannot retrieve all albums.'),
);
@override
FutureOrResult> getAllPhotos({int? start, int? limit}) async =>
Result.tryCatchAsync(
() => _photoRemoteDataSource.getAllPhotos(start: start, limit: limit),
- (error) => ServerException('Cannot retrieve all photos.'),
+ (error) => const ServerException('Cannot retrieve all photos.'),
);
@override
@@ -88,7 +88,7 @@ class PhotoRepositoryImpl extends PhotoRepository {
}
return Ok(response);
} catch (_) {
- return Err(
+ return const Err(
ClientException('Cannot retrieve all photos from favorites.'),
);
}
diff --git a/packages/wyatt_architecture/example/lib/domain/usecases/photos/add_photo_to_favorites.dart b/packages/wyatt_architecture/example/lib/domain/usecases/photos/add_photo_to_favorites.dart
index 769ae81d..ef8a0ec9 100644
--- a/packages/wyatt_architecture/example/lib/domain/usecases/photos/add_photo_to_favorites.dart
+++ b/packages/wyatt_architecture/example/lib/domain/usecases/photos/add_photo_to_favorites.dart
@@ -33,7 +33,7 @@ class AddPhotoToFavorites extends AsyncUseCase> {
@override
FutureOr onStart(Photo? params) {
if (params == null) {
- throw ClientException('Photo cannot be null');
+ throw const ClientException('Photo cannot be null');
}
}
}
diff --git a/packages/wyatt_architecture/example/lib/domain/usecases/photos/check_if_photo_is_in_favorites.dart b/packages/wyatt_architecture/example/lib/domain/usecases/photos/check_if_photo_is_in_favorites.dart
index 7ff464ce..f0dcfa5c 100644
--- a/packages/wyatt_architecture/example/lib/domain/usecases/photos/check_if_photo_is_in_favorites.dart
+++ b/packages/wyatt_architecture/example/lib/domain/usecases/photos/check_if_photo_is_in_favorites.dart
@@ -30,7 +30,7 @@ class CheckIfPhotoIsInFavorites extends AsyncUseCase {
@override
FutureOr onStart(int? params) {
if (params == null) {
- throw ClientException('id cannot be null');
+ throw const ClientException('id cannot be null');
}
}
}
diff --git a/packages/wyatt_architecture/example/lib/domain/usecases/photos/display_photo.dart b/packages/wyatt_architecture/example/lib/domain/usecases/photos/display_photo.dart
index 36076c70..79a06b8a 100644
--- a/packages/wyatt_architecture/example/lib/domain/usecases/photos/display_photo.dart
+++ b/packages/wyatt_architecture/example/lib/domain/usecases/photos/display_photo.dart
@@ -33,7 +33,7 @@ class DisplayPhoto extends AsyncUseCase {
@override
FutureOr onStart(int? params) {
if (params == null) {
- throw ClientException('id cannot be null');
+ throw const ClientException('id cannot be null');
}
}
}
diff --git a/packages/wyatt_architecture/example/lib/domain/usecases/photos/open_album.dart b/packages/wyatt_architecture/example/lib/domain/usecases/photos/open_album.dart
index 8badf689..358e86a2 100644
--- a/packages/wyatt_architecture/example/lib/domain/usecases/photos/open_album.dart
+++ b/packages/wyatt_architecture/example/lib/domain/usecases/photos/open_album.dart
@@ -39,7 +39,7 @@ class OpenAlbum extends AsyncUseCase> {
@override
FutureOr onStart(QueryParameters? params) {
if (params == null) {
- throw ClientException('params cannot be null');
+ throw const ClientException('params cannot be null');
}
}
}
diff --git a/packages/wyatt_architecture/example/lib/domain/usecases/photos/remove_photo_from_favorites.dart b/packages/wyatt_architecture/example/lib/domain/usecases/photos/remove_photo_from_favorites.dart
index 737c59a1..e73206b3 100644
--- a/packages/wyatt_architecture/example/lib/domain/usecases/photos/remove_photo_from_favorites.dart
+++ b/packages/wyatt_architecture/example/lib/domain/usecases/photos/remove_photo_from_favorites.dart
@@ -33,7 +33,7 @@ class RemovePhotoFromFavorites extends AsyncUseCase> {
@override
FutureOr onStart(int? params) {
if (params == null) {
- throw ClientException('id cannot be null');
+ throw const ClientException('id cannot be null');
}
}
}
diff --git a/packages/wyatt_architecture/example/lib/domain/usecases/photos/retrieve_all_albums.dart b/packages/wyatt_architecture/example/lib/domain/usecases/photos/retrieve_all_albums.dart
index 0fc6a757..e88f8a12 100644
--- a/packages/wyatt_architecture/example/lib/domain/usecases/photos/retrieve_all_albums.dart
+++ b/packages/wyatt_architecture/example/lib/domain/usecases/photos/retrieve_all_albums.dart
@@ -37,7 +37,7 @@ class RetrieveAllAlbums extends AsyncUseCase> {
@override
FutureOr onStart(QueryParameters? params) {
if (params == null) {
- throw ClientException('params cannot be null');
+ throw const ClientException('params cannot be null');
}
}
}
diff --git a/packages/wyatt_architecture/lib/src/core/exceptions/exceptions.dart b/packages/wyatt_architecture/lib/src/core/exceptions/exceptions.dart
index 3fb15944..e1fa8e9a 100644
--- a/packages/wyatt_architecture/lib/src/core/exceptions/exceptions.dart
+++ b/packages/wyatt_architecture/lib/src/core/exceptions/exceptions.dart
@@ -16,8 +16,13 @@
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
+/// {@template app_exception}
+/// [AppException] is a base class for all exceptions in the wyatt architecture.
+/// {@endtemplate}
abstract class AppException implements Exception {
- AppException([this.message]);
+ /// {@macro app_exception}
+ const AppException([this.message]);
+
final String? message;
@override
@@ -30,10 +35,20 @@ abstract class AppException implements Exception {
}
}
+/// {@template client_exception}
+/// [ClientException] is a base class for all client exceptions in the wyatt
+/// architecture.
+/// {@endtemplate}
class ClientException extends AppException {
- ClientException([super.message]);
+ /// {@macro client_exception}
+ const ClientException([super.message]);
}
+/// {@template server_exception}
+/// [ServerException] is a base class for all server exceptions in the wyatt
+/// architecture.
+/// {@endtemplate}
class ServerException extends AppException {
- ServerException([super.message]);
+ /// {@macro server_exception}
+ const ServerException([super.message]);
}
diff --git a/packages/wyatt_architecture/lib/src/domain/data_sources/base_data_source.dart b/packages/wyatt_architecture/lib/src/domain/data_sources/base_data_source.dart
index 5dc243db..f5002603 100644
--- a/packages/wyatt_architecture/lib/src/domain/data_sources/base_data_source.dart
+++ b/packages/wyatt_architecture/lib/src/domain/data_sources/base_data_source.dart
@@ -14,6 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+/// {@template base_data_source}
+/// [BaseDataSource] is a base class for all data sources in the wyatt
+/// architecture.
+/// {@endtemplate}
abstract class BaseDataSource {
+ /// {@macro base_data_source}
const BaseDataSource();
}
diff --git a/packages/wyatt_architecture/lib/src/domain/data_sources/local/base_local_data_source.dart b/packages/wyatt_architecture/lib/src/domain/data_sources/local/base_local_data_source.dart
index 1d7c134c..b091a13f 100644
--- a/packages/wyatt_architecture/lib/src/domain/data_sources/local/base_local_data_source.dart
+++ b/packages/wyatt_architecture/lib/src/domain/data_sources/local/base_local_data_source.dart
@@ -16,6 +16,11 @@
import 'package:wyatt_architecture/src/domain/data_sources/base_data_source.dart';
+/// {@template base_local_data_source}
+/// [BaseLocalDataSource] is a base class for all local data sources in the
+/// wyatt architecture.
+/// {@endtemplate}
abstract class BaseLocalDataSource extends BaseDataSource {
+ /// {@macro base_local_data_source}
const BaseLocalDataSource();
}
diff --git a/packages/wyatt_architecture/lib/src/domain/data_sources/remote/base_remote_data_source.dart b/packages/wyatt_architecture/lib/src/domain/data_sources/remote/base_remote_data_source.dart
index a4a72999..8ed880c4 100644
--- a/packages/wyatt_architecture/lib/src/domain/data_sources/remote/base_remote_data_source.dart
+++ b/packages/wyatt_architecture/lib/src/domain/data_sources/remote/base_remote_data_source.dart
@@ -16,6 +16,11 @@
import 'package:wyatt_architecture/src/domain/data_sources/base_data_source.dart';
+/// {@template base_remote_data_source}
+/// [BaseRemoteDataSource] is a base class for all remote data sources in the
+/// wyatt architecture.
+/// {@endtemplate}
abstract class BaseRemoteDataSource extends BaseDataSource {
+ /// {@macro base_remote_data_source}
const BaseRemoteDataSource();
}
diff --git a/packages/wyatt_architecture/lib/src/domain/entities/entity.dart b/packages/wyatt_architecture/lib/src/domain/entities/entity.dart
index fd988950..41a8ca17 100644
--- a/packages/wyatt_architecture/lib/src/domain/entities/entity.dart
+++ b/packages/wyatt_architecture/lib/src/domain/entities/entity.dart
@@ -14,6 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+/// {@template entity}
+/// [Entity] is a base class for all entities in the domain layer.
+/// {@endtemplate}
abstract class Entity {
+ /// {@macro entity}
const Entity();
}
diff --git a/packages/wyatt_architecture/lib/src/domain/repositories/base_repository.dart b/packages/wyatt_architecture/lib/src/domain/repositories/base_repository.dart
index 4a08a0db..a7e26b12 100644
--- a/packages/wyatt_architecture/lib/src/domain/repositories/base_repository.dart
+++ b/packages/wyatt_architecture/lib/src/domain/repositories/base_repository.dart
@@ -14,6 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+/// {@template base_repository}
+/// [BaseRepository] is a base class for all repositories in the domain layer.
+/// {@endtemplate}
abstract class BaseRepository {
+ /// {@macro base_repository}
const BaseRepository();
}
diff --git a/packages/wyatt_architecture/lib/src/domain/usecases/no_param.dart b/packages/wyatt_architecture/lib/src/domain/usecases/no_param.dart
index 7452af67..4509bd59 100644
--- a/packages/wyatt_architecture/lib/src/domain/usecases/no_param.dart
+++ b/packages/wyatt_architecture/lib/src/domain/usecases/no_param.dart
@@ -16,6 +16,11 @@
import 'package:wyatt_architecture/src/domain/entities/entity.dart';
+/// {@template no_param}
+/// [NoParam] is a class that is used when a use case does not require any
+/// parameters.
+/// {@endtemplate}
class NoParam extends Entity {
+ /// {@macro no_param}
const NoParam();
}
diff --git a/packages/wyatt_architecture/lib/src/domain/usecases/observers.dart b/packages/wyatt_architecture/lib/src/domain/usecases/observers.dart
index 370546fe..a1925577 100644
--- a/packages/wyatt_architecture/lib/src/domain/usecases/observers.dart
+++ b/packages/wyatt_architecture/lib/src/domain/usecases/observers.dart
@@ -21,16 +21,17 @@ import 'package:wyatt_architecture/wyatt_architecture.dart';
/// Usecase observers
mixin Observer {
/// Called before usecase is runned.
- /// Usefull to check the preconditions
+ /// Useful to check the preconditions
FutureOr onStart(Parameters? params) {}
/// Called when error occures during main scenario
- /// Usefull to run alternative scenario
+ /// Useful to run alternative scenario
FutureOr onError(AppException? error) {}
}
/// Specific observer for classic usecase
mixin AsyncObserver {
+ /// Called when usecase is completed
FutureOr onComplete(ReturnType? data) {}
}
@@ -39,6 +40,6 @@ mixin StreamObserver {
/// Replaces the data event handler of this subscription.
void onDone() {}
- /// Replaces the done event handler of this subscription.
+ /// Replaces the done event handler of this subscription.
void onData(ReturnType? data) {}
}
diff --git a/packages/wyatt_architecture/lib/src/domain/usecases/usecase.dart b/packages/wyatt_architecture/lib/src/domain/usecases/usecase.dart
index c406535d..75c4c905 100644
--- a/packages/wyatt_architecture/lib/src/domain/usecases/usecase.dart
+++ b/packages/wyatt_architecture/lib/src/domain/usecases/usecase.dart
@@ -23,8 +23,13 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
typedef FutureOrResult = FutureOr>;
typedef StreamResult = Stream>;
-/// Abstract class of a use case
+/// {@template base_usecase}
+/// Abstract class of any use case.
+/// {@endtemplate}
abstract class BaseUseCase {
+ /// {@macro base_usecase}
+ const BaseUseCase();
+
/// Run use case scenarios
ReturnType call(Parameters parameters);
@@ -33,11 +38,16 @@ abstract class BaseUseCase {
ReturnType execute(Parameters params);
}
+/// {@template usecase}
/// Abstract class of a use case that deals specifically
/// with the response and its state.
+/// {@endtemplate}
abstract class UseCase
extends BaseUseCase>
with Observer {
+ /// {@macro usecase}
+ const UseCase();
+
FutureOr _onSuccess(ReturnType data);
/// Supports the result of the main scenario and integrates
@@ -59,17 +69,27 @@ abstract class UseCase
}
}
-/// Abtstract classic usecase.
+/// {@template async_usecase}
+/// Abtstract classic usecase bases on futures
+/// {@endtemplate}
abstract class AsyncUseCase
extends UseCase with AsyncObserver {
+ /// {@macro async_usecase}
+ const AsyncUseCase();
+
@override
FutureOr _onSuccess(ReturnType data) => onComplete(data);
}
+/// {@template stream_usecase}
/// Abstract specific usecase bases on streams
+/// {@endtemplate}
abstract class StreamUseCase
extends UseCase>
with StreamObserver {
+ /// {@macro stream_usecase}
+ const StreamUseCase();
+
@override
FutureOr _onSuccess(Stream data) {
data.listen(
diff --git a/packages/wyatt_architecture/lib/wyatt_architecture.dart b/packages/wyatt_architecture/lib/wyatt_architecture.dart
index 54c20e0d..f07613aa 100644
--- a/packages/wyatt_architecture/lib/wyatt_architecture.dart
+++ b/packages/wyatt_architecture/lib/wyatt_architecture.dart
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-/// Architecture
+/// Wyatt Architecture for Flutter
library wyatt_architecture;
export 'src/src.dart';
diff --git a/packages/wyatt_architecture/pubspec.yaml b/packages/wyatt_architecture/pubspec.yaml
index cac59f5f..dafcc4eb 100644
--- a/packages/wyatt_architecture/pubspec.yaml
+++ b/packages/wyatt_architecture/pubspec.yaml
@@ -1,27 +1,23 @@
name: wyatt_architecture
-description: A new Wyatt package
+description: Wyatt Architecture contains useful classes to help you to create a clean architecture following the Wyatt Architecture principles.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_architecture
version: 0.1.0+1
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
environment:
- sdk: '>=2.17.0 <3.0.0'
+ sdk: ">=2.17.0 <3.0.0"
dependencies:
-
- flutter:
- sdk: flutter
+ flutter: { sdk: flutter }
wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.0.4
dev_dependencies:
-
- flutter_test:
- sdk: flutter
-
+ flutter_test: { sdk: flutter }
+
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
- version: ^2.4.1
\ No newline at end of file
+ version: ^2.4.1