feat : Modèle avec sérialisation automatique

This commit is contained in:
Yaël Perret
2026-05-05 21:52:13 +02:00
parent 93a54ae19b
commit d88b32d8f2
13 changed files with 404 additions and 89 deletions

30
lib/models/event.dart Normal file
View File

@@ -0,0 +1,30 @@
import 'package:json_annotation/json_annotation.dart';
part 'event.g.dart';
@JsonSerializable()
class Event {
String name;
String picture;
String organizer = 'Organizer';
String? place;
DateTime? date;
bool isFavorite;
Event({
required this.name,
required this.picture,
required this.organizer,
this.date,
this.place,
this.isFavorite = false,
});
@override
String toString() {
return 'Event{name: $name, picture: $picture}';
}
factory Event.fromJson(Map<String, dynamic> json) => _$EventFromJson(json);
Map<String, dynamic> toJson() => _$EventToJson(this);
}