Run the following codes in terminal to run the project :
dart run build_runner build
To run this project you will need to add the following environment variables to the .env file in the assets/env folder
BASE_URL = "API BASE URL"
The foldering of the project is as follows ->
- Core
- Feature
- Model
- Service
Null management in projects has always been a challenge for me. For this reason, I managed null in the service layer of the project. I completely eliminated the responsibility of null to the view and view-model. Thanks to the Resource class, I return exception type in case of error or null data. In this way, operations on the view and view-model side become much easier. I share the resource class below.
sealed class Resource<T> {
const Resource({this.data, this.exceptionType});
final T? data;
final ExceptionTypes? exceptionType;
}
class SuccessState<T> extends Resource<T> {
const SuccessState(T data) : super(data: data);
}
class ErrorState<T> extends Resource<T> {
const ErrorState(ExceptionTypes type, [T? data]) : super(data: data, exceptionType: type);
}
class LoadingState<T> extends Resource<T> {
const LoadingState() : super();
}