Files
tuiche/lib/model/api_response.dart
2025-04-28 15:37:58 +08:00

18 lines
456 B
Dart

class ApiResponse<T> {
int? code;
T? data;
String? msg;
int? total;
ApiResponse({required this.code, this.data, this.msg, this.total});
factory ApiResponse.fromJson(
Map<String, dynamic> json, T Function(Object?) fromJsonT) {
return ApiResponse<T>(
code: json['code'] as int,
data: json['data'] != null ? fromJsonT(json['data']) : null,
msg: json['msg'] as String?,
total: json['total'] as int?,
);
}
}