when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. bool dailyReminderEnabled,
    2. int dailyReminderHour,
    3. int dailyReminderMinute,
    4. bool streakAlertEnabled,
    5. bool overdueAlertEnabled,
    6. int overdueThresholdDays,
    )
)

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool dailyReminderEnabled,  int dailyReminderHour,  int dailyReminderMinute,  bool streakAlertEnabled,  bool overdueAlertEnabled,  int overdueThresholdDays)  $default,) {final _that = this;
switch (_that) {
case _NotificationPreferences():
return $default(_that.dailyReminderEnabled,_that.dailyReminderHour,_that.dailyReminderMinute,_that.streakAlertEnabled,_that.overdueAlertEnabled,_that.overdueThresholdDays);case _:
  throw StateError('Unexpected subclass');

}
}