#StackBounty: #dart #repository-pattern #clean-architecture passing interface as a argument in between usecases and repositories

Bounty: 50

I want to pass interface as a request in my use cases and repositories while following the clean architecture in flutter

hence my method signature is as follows for usecases and respositories respectively.

Future<Either<Failure, ResponseData>> call(IRequest params) // use case
Future<Either<Failure, ResponseData>> updateUserProfile(IRequest request); // repository

Now request entities and models are as follows

class UserProfileRequestData  implements IRequest{

  late final int id;
  late final String first_name;
  late final String last_name;
      {required this.id,
      required this.first_name,
      required this.last_name});
  Object toRequest() {
    // TODO: implement toRequest
    throw UnimplementedError();

class UserProfileRequestDataModel extends UserProfileRequestData implements IRequest {

        required int id,
        required String first_name,
        required String last_name,}):super( id: id,
            first_name: first_name,
            last_name: last_name,);
     Map<String, dynamic> toJson() {
    return {
      "first_name": first_name,
      "last_name": last_name,
      "id": id,
  Map<String, dynamic> toRequest() => toJson();


Now, what I am expecting is whenever the user passes UserProfileRequestData as an entity from UI and in repository if I execture request.toRequest() then it should call UserProfileRequestDataModel‘s toRequest() function and not the parent class one.

here is the sample code for this problem statement

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.