swagger_generator_flutter/example/lib/common/base_page_result.dart

28 lines
672 B
Dart

import 'package:json_annotation/json_annotation.dart';
part 'base_page_result.g.dart';
@JsonSerializable(
checked: true,
genericArgumentFactories: true,
fieldRename: FieldRename.snake,
)
class BasePageResult<T> extends Object {
BasePageResult({required this.items, required this.total});
@JsonKey(name: 'items')
final List<T> items;
@JsonKey(name: 'total')
final int total;
factory BasePageResult.fromJson(
Map<String, dynamic> json,
T Function(dynamic json) fromJsonT,
) =>
_$BasePageResultFromJson(json, fromJsonT);
Map<String, dynamic> toJson(Object Function(T value) toJsonT) =>
_$BasePageResultToJson(this, toJsonT);
}