Files
blog_app/lib/models/common.dart
2025-11-14 23:22:01 +08:00

38 lines
807 B
Dart

import 'package:json_annotation/json_annotation.dart';
part 'common.g.dart';
@JsonSerializable(genericArgumentFactories: true)
class PageResult<T> {
@JsonKey(name: 'records')
final List<T> records;
@JsonKey(name: 'total')
final int total;
@JsonKey(name: 'size')
final int size;
@JsonKey(name: 'current')
final int current;
@JsonKey(name: 'pages')
final int pages;
const PageResult({
required this.records,
required this.total,
required this.size,
required this.current,
required this.pages,
});
factory PageResult.fromJson(
Map<String, dynamic> json,
T Function(Object? json) fromJsonT,
) => _$PageResultFromJson(json, fromJsonT);
Map<String, dynamic> toJson(Object? Function(T value) toJsonT) =>
_$PageResultToJson(this, toJsonT);
}