mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
Update
This commit is contained in:
22
lib/api/api_result.dart
Normal file
22
lib/api/api_result.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'api_result.g.dart';
|
||||
|
||||
@JsonSerializable(genericArgumentFactories: true)
|
||||
class ApiResult<T> {
|
||||
const ApiResult({
|
||||
required this.ok,
|
||||
required this.status,
|
||||
this.data,
|
||||
this.error,
|
||||
});
|
||||
factory ApiResult.fromJson(
|
||||
Map<String, dynamic> json, T Function(Object?) fromJsonT) =>
|
||||
_$ApiResultFromJson(json, fromJsonT);
|
||||
final bool ok;
|
||||
final int status;
|
||||
final T? data;
|
||||
final String? error;
|
||||
Map<String, dynamic> toJson(Object? Function(T) toJsonT) =>
|
||||
_$ApiResultToJson(this, toJsonT);
|
||||
}
|
||||
Reference in New Issue
Block a user