wip, immutable types
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'user_dto.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class UserDto {
|
||||
final String id;
|
||||
final String name;
|
||||
final String email;
|
||||
|
||||
// Optional: Füge zusätzliche Felder wie Timestamps hinzu
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
UserDto({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.email,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
/// Factory-Methode zur Deserialisierung von JSON
|
||||
factory UserDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$UserDtoFromJson(json);
|
||||
|
||||
/// Methode zur Serialisierung nach JSON
|
||||
Map<String, dynamic> toJson() => _$UserDtoToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
UserDto _$UserDtoFromJson(Map<String, dynamic> json) => UserDto(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
email: json['email'] as String,
|
||||
createdAt: json['createdAt'] == null
|
||||
? null
|
||||
: DateTime.parse(json['createdAt'] as String),
|
||||
updatedAt: json['updatedAt'] == null
|
||||
? null
|
||||
: DateTime.parse(json['updatedAt'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UserDtoToJson(UserDto instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'email': instance.email,
|
||||
'createdAt': instance.createdAt?.toIso8601String(),
|
||||
'updatedAt': instance.updatedAt?.toIso8601String(),
|
||||
};
|
||||
Reference in New Issue
Block a user