Skip to content

Generic Class is not defined in Reflection.factories #3

Description

@rasyadh

I have class model BaseResponses

import 'package:object_mapper/object_mapper.dart';

class BaseResponses<T> with Mappable {
  String message;
  T data;

  @override
  void mapping(Mapper map) {
    map('message', message, (v) => message = v);
    map<T>('data', data, (v) => data = v);
  }
}

and also register it in mappable factories

Mappable.factories = {
  BaseResponses: () => BaseResponses(),
};

I try to convert json to BaseResponses which T is another class model, on this case is Customer.
But when I try to call it like this:

BaseResponses<T> baseResponses = Mapper.fromJson(responseData).toObject<BaseResponses<T>>();

I got an error its throw execution error with message:

BaseResponses<Customer> is not defined in Reflection.factories

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions