import '../../../../api/mhsl/custom_timetable_event/custom_timetable_event.dart'; import '../../../../api/webuntis/queries/get_timetable/get_timetable_response.dart'; sealed class ArbitraryAppointment { const ArbitraryAppointment(); T when({ required T Function(GetTimetableResponseObject lesson) webuntis, required T Function(CustomTimetableEvent event) custom, }) => switch (this) { WebuntisAppointment(:final lesson) => webuntis(lesson), CustomAppointment(:final event) => custom(event), }; } class WebuntisAppointment extends ArbitraryAppointment { final GetTimetableResponseObject lesson; const WebuntisAppointment(this.lesson); } class CustomAppointment extends ArbitraryAppointment { final CustomTimetableEvent event; const CustomAppointment(this.event); }