maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. Map<String, LedgerSessionMetrics> sessionsById,
    2. Map<String, List<LedgerSessionMetrics>> sessionsByLane,
    3. FalseFMetrics falseFs,
    4. CacheTokenTotals cacheTokens,
    5. double? cacheHitRatio,
    6. Map<String, int> reworkRoundsByWorkBead,
    7. LandedDeliveryTotals landedDeliveries,
    8. double? costPerLandedDelivery,
    9. Map<String, Map<LedgerGrade, int>> gradeDistributionByLane,
    10. List<MetricsDecodeIssue> issues,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( Map<String, LedgerSessionMetrics> sessionsById,  Map<String, List<LedgerSessionMetrics>> sessionsByLane,  FalseFMetrics falseFs,  CacheTokenTotals cacheTokens,  double? cacheHitRatio,  Map<String, int> reworkRoundsByWorkBead,  LandedDeliveryTotals landedDeliveries,  double? costPerLandedDelivery,  Map<String, Map<LedgerGrade, int>> gradeDistributionByLane,  List<MetricsDecodeIssue> issues)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _SessionLedgerMetricsProjection() when $default != null:
return $default(_that.sessionsById,_that.sessionsByLane,_that.falseFs,_that.cacheTokens,_that.cacheHitRatio,_that.reworkRoundsByWorkBead,_that.landedDeliveries,_that.costPerLandedDelivery,_that.gradeDistributionByLane,_that.issues);case _:
  return orElse();

}
}