import 'package:json_annotation/json_annotation.dart'; part 'api_response.g.dart'; @JsonSerializable(genericArgumentFactories: true) class ApiResponse { T? data; int code = 200; String msg = ""; ApiResponse(); factory ApiResponse.fromJson( Map json, T Function(Object? json) fromJsonT) => _$ApiResponseFromJson(json, fromJsonT); Map toJson(Object Function(T value) toJsonT) => _$ApiResponseToJson(this, toJsonT); bool get isSuccess => code == 200; }