when<R extends Object> method
Creates a conditional expression (ternary operator).
This method can only be called on boolean expressions (like BooleanParam or comparison results).
Example:
final isProduction = defineBoolean('IS_PRODUCTION');
final region = isProduction.when(
then: LiteralExpression(['us-central1', 'europe-west1']),
otherwise: LiteralExpression(['us-central1']),
);
Implementation
If<R> when<R extends Object>({
required Expression<R> then,
required Expression<R> otherwise,
}) {
if (this is! Expression<bool>) {
throw ArgumentError('when() can only be called on Expression<bool>');
}
return If(this as Expression<bool>, then: then, otherwise: otherwise);
}