i am trying to make MainResponse class which is returned from backend with same format. I have created a Data class and the object it has should be generic json key regarding the class name like below:
import 'package:json_annotation/json_annotation.dart';
import 'package:style/api/response/status_response.dart';
part 'data.g.dart';
@JsonSerializable(genericArgumentFactories: true)
class Data<T> {
@JsonKey(name: T.toString())
T? returnedObject;
}
what I wanted to do is giving JsonKey name value as class name. but i am receiving following error:
Arguments of a constant creation must be constant expressions.
is there a way to achieve it?